This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
giganet:sflow [2021/08/02 13:10] rb |
giganet:sflow [2021/08/03 13:28] (current) rb |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Схема мониторинга sflow статистики ====== | ||
- | |||
- | ===== Задействованные сервера ===== | ||
- | |||
- | * **goflow **- сервер на котором крутится kafka и goflow2 приложение по сбору статистики | ||
- | * **clickhouse **- сервер с базой данных clickhouse, хранение и обработка статистики | ||
- | ===== Задействованные приложения ===== | ||
- | |||
- | * **goflow2** | ||
- | * **kafka** | ||
- | * **clickhouse** | ||
===== Общая схема мониторинга ===== | ===== Общая схема мониторинга ===== | ||
Line 28: | Line 17: | ||
примеры конфигов для свитчей | примеры конфигов для свитчей | ||
+ | |||
+ | < | ||
+ | sampling.1G = 8192 | ||
+ | sampling.10G = 8192 | ||
+ | sampling.40G = 16384 | ||
+ | sampling.100G = 32768 | ||
+ | |||
+ | </ | ||
==== goflow2 ==== | ==== goflow2 ==== | ||
- | пример настройки | + | file / |
+ | |||
+ | < | ||
+ | GOFLOW2_ARGS=-format pb -format.protobuf.fixedlen=true -listen=sflow:// | ||
+ | |||
+ | </ | ||
==== kafka ==== | ==== kafka ==== | ||
- | пример | + | == Установка == |
+ | |||
+ | < | ||
+ | useradd kafka -m | ||
+ | passwd kafka | ||
+ | su -l kafka | ||
+ | cd | ||
+ | curl https:// | ||
+ | tar -xvzf kafka_2.13-2.8.0.tgz | ||
+ | ln -s / | ||
+ | |||
+ | </ | ||
+ | |||
+ | / | ||
+ | |||
+ | < | ||
+ | delete.topic.enable=true | ||
+ | |||
+ | </ | ||
+ | |||
+ | / | ||
+ | |||
+ | < | ||
+ | [Unit] | ||
+ | Requires=network.target remote-fs.target | ||
+ | After=network.target remote-fs.target | ||
+ | |||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=kafka | ||
+ | ExecStart=/ | ||
+ | ExecStop=/ | ||
+ | Restart=on-abnormal | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | |||
+ | </ | ||
+ | |||
+ | / | ||
+ | |||
+ | < | ||
+ | [Unit] | ||
+ | Requires=zookeeper.service | ||
+ | After=zookeeper.service | ||
+ | |||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=kafka | ||
+ | ExecStart=/ | ||
+ | ExecStop=/ | ||
+ | Restart=on-abnormal | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | |||
+ | </ | ||
+ | |||
+ | Запускаем сервисы | ||
+ | |||
+ | < | ||
+ | systemctl daemon-reload | ||
+ | systemctl start kafka | ||
+ | systemctl enable kafka | ||
+ | |||
+ | </ | ||
+ | |||
+ | Работаем с kafka | ||
+ | |||
+ | < | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | |||
+ | </ | ||
==== clickhouse ==== | ==== clickhouse ==== | ||
- | === таблица kafka === | + | === дополнительная |
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | |||
+ | === таблица kafka === | ||
< | < | ||
+ | |||
CREATE TABLE traffic.kafka | CREATE TABLE traffic.kafka | ||
( | ( | ||
Line 121: | Line 205: | ||
</ | </ | ||
+ | |||
==== таблица raw ==== | ==== таблица raw ==== | ||
Line 202: | Line 287: | ||
PARTITION BY toYYYYMMDD(Date) | PARTITION BY toYYYYMMDD(Date) | ||
ORDER BY Datetime | ORDER BY Datetime | ||
- | TTL Date + toIntervalDay(7) | + | TTL Date |
SETTINGS index_granularity = 8192 | SETTINGS index_granularity = 8192 | ||
</ | </ | ||
+ | |||
==== таблица kafka_to_raw ==== | ==== таблица kafka_to_raw ==== | ||
Line 347: | Line 433: | ||
MPLSLastLabel | MPLSLastLabel | ||
FROM traffic.kafka | FROM traffic.kafka | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== Словари ==== | ||
+ | |||
+ | protocols - словарь для текстового представления протоколов | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.protocols ( | ||
+ | `proto` UInt8, | ||
+ | `name` String, | ||
+ | `description` String | ||
+ | ) | ||
+ | PRIMARY KEY proto | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(FLAT()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | asnv4 - конвертация ipv4 к ASN | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.asnv4 | ||
+ | ( | ||
+ | `network` String, | ||
+ | `asn` UInt32, | ||
+ | `aso` String DEFAULT '??' | ||
+ | ) | ||
+ | PRIMARY KEY network | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(IP_TRIE()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | asnv6 - конвертация ipv6 к ASN | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.asnv6 | ||
+ | ( | ||
+ | `network` String, | ||
+ | `asn` UInt32, | ||
+ | `aso` String DEFAULT '??' | ||
+ | ) | ||
+ | PRIMARY KEY network | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(IP_TRIE()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | contryen | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.contryen | ||
+ | ( | ||
+ | `geoname_id` id, | ||
+ | `locale_code` String, | ||
+ | `continent_code` String, | ||
+ | `continent_name` String, | ||
+ | `country_iso_code` String, | ||
+ | `country_name` String, | ||
+ | `is_in_european_union` UInt8 | ||
+ | ) | ||
+ | PRIMARY KEY geoname_id | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(HASHED()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | contryv4 | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.contryv4 | ||
+ | ( | ||
+ | `network` String, | ||
+ | `geoname_id` UInt32 DEFAULT 0, | ||
+ | `registered_country_geoname_id` UInt32 DEFAULT 0, | ||
+ | `represented_country_geoname_id` UInt32 DEFAULT 0, | ||
+ | `is_anonymous_proxy` UInt8 DEFAULT 0, | ||
+ | `is_satellite_provider` UInt8 DEFAULT 0 | ||
+ | ) | ||
+ | PRIMARY KEY network | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(IP_TRIE()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | contryv6 | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.contryv6 | ||
+ | ( | ||
+ | `network` String, | ||
+ | `geoname_id` UInt32 DEFAULT 0, | ||
+ | `registered_country_geoname_id` UInt32 DEFAULT 0, | ||
+ | `represented_country_geoname_id` UInt32 DEFAULT 0, | ||
+ | `is_anonymous_proxy` UInt8 DEFAULT 0, | ||
+ | `is_satellite_provider` UInt8 DEFAULT 0 | ||
+ | ) | ||
+ | PRIMARY KEY network | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(IP_TRIE()) | ||
+ | |||
+ | </ | ||
+ | |||
+ | switches | ||
+ | |||
+ | < | ||
+ | CREATE DICTIONARY dictionaries.switches | ||
+ | ( | ||
+ | `ip` String, | ||
+ | `name` String | ||
+ | ) | ||
+ | PRIMARY KEY ip | ||
+ | SOURCE(FILE(PATH '/ | ||
+ | LIFETIME(MIN 0 MAX 3600) | ||
+ | LAYOUT(COMPLEX_KEY_HASHED()) | ||
</ | </ | ||