Hiresaka momba ilay tetikasa ity lahatsoratra ity nginx-log-collector, izay hamaky ny log nginx, alefaso any amin'ny cluster Clickhouse. Matetika ny ElasticSearch dia ampiasaina amin'ny logs. Ny Clickhouse dia mitaky loharanon-karena vitsy kokoa (espace disk, RAM, CPU). Manoratra angona haingana kokoa ny Clickhouse. Clickhouse dia manindry ny angon-drakitra, izay mahatonga ny angona ao amin'ny kapila ho maivana kokoa. Ny tombony amin'ny Clickhouse dia azo jerena amin'ny sary 2 avy amin'ny tatitra Ahoana ny fampidirana ny angona VK ao amin'ny ClickHouse avy amin'ny mpizara an'aliny.
Raha hijery ny analyse amin'ny alàlan'ny logs, andao hamorona dashboard ho an'ny Grafana.
Ao amin'io rakitra Ny fangatahana SQL amin'ny famoronana angon-drakitra sy tabilao ho an'ny nginx-log-collector ao amin'ny Clickhouse dia nofaritana.
Manao ny fangatahana tsirairay izahay amin'ny mpizara tsirairay ao amin'ny cluster Clickhouse.
Fanamarihana manan-danja. Amin'ity andalana ity, ny logs_cluster dia tokony hosoloina ny anaran'ny cluster avy amin'ny rakitra clickhouse_remote_servers.xml eo anelanelan'ny "remote_servers" sy ny "shard".
upstream backend {
server ip-адрес-сервера-с-stub_http_server:8080;
server ip-адрес-сервера-с-stub_http_server:8080;
server ip-адрес-сервера-с-stub_http_server:8080;
server ip-адрес-сервера-с-stub_http_server:8080;
server ip-адрес-сервера-с-stub_http_server:8080;
}
server {
listen 80;
server_name vhost1;
location / {
proxy_pass http://backend;
}
}
SELECT
1 as t,
count(*) as c
FROM $table
WHERE $timeFilter GROUP BY t
Fangatahana tsy nahomby ny Singlestat:
SELECT
1 as t,
count(*) as c
FROM $table
WHERE $timeFilter AND status NOT IN (200, 201, 401) GROUP BY t
Isan-jato tsy nahomby ny Singlestat:
SELECT
1 as t, (sum(status = 500 or status = 499)/sum(status = 200 or status = 201 or status = 401))*100 FROM $table
WHERE $timeFilter GROUP BY t
Fotoana mamaly salan'isa Singlestat:
SELECT
1, avg(request_time) FROM $table
WHERE $timeFilter GROUP BY 1
Fotoana mamaly max Singlestat:
SELECT
1 as t, max(request_time) as c
FROM $table
WHERE $timeFilter GROUP BY t
Sata fanisana:
$columns(status, count(*) as c) from $table
Mba hamoahana angona toy ny pie dia mila mametraka ny plugin ianao ary mamerina ny grafana.
grafana-cli plugins install grafana-piechart-panel
service grafana-server restart
Sata TOP 5 Pie:
SELECT
1, /* fake timestamp value */
status,
sum(status) AS Reqs
FROM $table
WHERE $timeFilter
GROUP BY status
ORDER BY Reqs desc
LIMIT 5
Hanome fangatahana tsy misy pikantsary aho:
Manisa http_user_agent:
$columns(http_user_agent, count(*) c) FROM $table
Sara tsara/ratsy:
$rate(countIf(status = 200) AS good, countIf(status != 200) AS bad) FROM $table
fotoana mamaly:
$rate(avg(request_time) as request_time) FROM $table
Fotoana famaliana an-tampony (fotoana famaliana ny 1er ambony):
$rate(avg(arrayElement(upstream_response_time,1)) as upstream_response_time) FROM $table
Sata fanisana latabatra ho an'ny vhost rehetra:
$columns(status, count(*) as c) from $table
Fijery ankapobeny ny dashboard
Mampitaha avg() sy quantille()
avg ()
quantille ()
famaranana:
Antenaina fa handray anjara amin'ny famolavolana/fitsapana sy fampiasana ny nginx-log-collector ny vondrom-piarahamonina.
Ary rehefa misy mampihatra ny nginx-log-collector dia holazainy aminao ny habetsahan'ny kapila, RAM, CPU.