nginx+rsyslog+kafka+clickhouse+grafana 实现nginx 网关监控

需求

  • 我想做一个类似腾讯云网关日志最终以仪表方式呈现,比如说qps、p99、p95的请求响应时间等等

流程图

数据流转就像标题
nginx ----> rsyslog ----> kafka —> clickhouse —> grafana

部署

kafka

kafka 相关部署这里不做赘述,只要创建一个topic 就可以
这里kafka地址是 192.168.1.180,topic是``

rsyslog 设置

rsyslog 具体是啥东西这个我这里也不做介绍,本人也是一个后端开发不是做运维的,只知道这个东西性能不错,算是logstash 平替把

# 安装rsyslog-kafka 插件
yum install -y rsyslog-kafka
# 创建一个配置vim /etc/rsyslog.d/rsyslog_nginx_kafka_cluster.conf

conf 内容

module(load="imudp")
input(type="imudp" port="514")# nginx access log ==> rsyslog server(local) ==> kafka
module(load="omkafka")template(name="nginxLog" type="string" string="%msg%")if $inputname == "imudp" then {# 这里的名字和下面nginx 配置tag 相同if ($programname == "nginx_access_log") thenaction(type="omkafka"template="nginxLog"# kafka 地址broker=["192.168.1.180:9092"]# topic 名字topic="rsyslog_nginx"partitions.auto="on"confParam=["socket.keepalive.enable=true"])
}:rawmsg, contains, "nginx_access_log" ~

最后重启rsyslog 即可

nginx

http 节点中设置如下

log_format jsonlog '{''"host": "$host",''"server_addr": "$server_addr",''"remote_addr":"$remote_addr",''"time_format":"$time_ms",''"time_sec":$times,''"timestamp":$timestamp,''"method":"$request_method",''"request_url":"$request_uri",''"status":$status,''"upstream_name":"$upstream_name",''"http_user_agent":"$http_user_agent",''"upstream_addr":"$upstream_addr",''"trace_id":"$http_traceid",''"upstream_status":"$upstream_status",''"upstream_response_time":"$upstream_response_time",''"request_time":$request_time,''"nginx_host":"$nginx_host"''}';# 配置rsyslog,tag 和上文rsyslog 中相同!!!access_log syslog:server=192.168.1.179,facility=local7,tag=nginx_access_log,severity=info jsonlog;#access_log  /var/log/nginx/access.log  jsonlog;

配置实际转发upstream

upstream testcontrol{server 192.168.10.123:8081;
}server {listen       18081;server_name  _;# 设置up nameset $upstream_name 'testcontrol';include /etc/nginx/conf/time.conf;location / {proxy_set_header traceid $http_traceid;proxy_set_header n-t $msec;#proxy_set_header X-Real-IP $remote_addr;proxy_pass http://testcontrol;}location ~ /status {stub_status   on;}
}

/etc/nginx/conf/time.conf; 配置

set $nginx_host '192.168.8.64';
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})") {set $year $1;set $month $2;set $day $3;set $hour $4;set $minutes $5;set $seconds $6;set $time_sec "$1-$2-$3 $4:$5:$6";}# 获取毫秒时间戳,并拼接到$time_zh之后if ($msec ~ "(\d+)\.(\d+)") {# 时间戳-msset $timestamp $1$2;# 时间戳-sset $times $1;# 格式化之后的时间msset $time_ms $time_sec.$2;# traceId,方便查日志set $http_traceid $nginx_host#$timestamp#$request_id;
}

clickhouse

先创建一个 nginx_gw_log 表


create table app_logs.nginx_gw_log
(timestamp              DateTime64(3, 'Asia/Shanghai'),server_addr            String,remote_addr            String,time_sec               DateTime('Asia/Shanghai'),method                 String,request_url            String,status                 Int16,upstream_name          String,http_user_agent        String,upstream_addr          String,trace_id               String,upstream_status        String,upstream_response_time String,request_time           Int32,nginx_host              String,host                   String
) engine = MergeTree PARTITION BY toYYYYMMDD(timestamp)ORDER BY timestampTTL toDateTime(timestamp) + toIntervalDay(1);

上面设置了过期1天,可以自由修改
添加kafka 引擎

create table app_logs.nginx_gw_log_kafka
(timestamp              DateTime64(3, 'Asia/Shanghai'),server_addr            String,remote_addr            String,time_sec               DateTime('Asia/Shanghai'),method                 String,request_url            String,status                 Int32,upstream_name          String,http_user_agent        String,upstream_addr          String,trace_id               String,upstream_status        String,upstream_response_time String,request_time           Decimal32(3),nginx_host              String,host                   String
) engine = Kafka()SETTINGS kafka_broker_list = '192.168.1.180:9092',kafka_topic_list = 'rsyslog_nginx',kafka_group_name = 'nginx_ck',kafka_format = 'JSONEachRow',kafka_skip_broken_messages = 100000,kafka_num_consumers = 1;

最后设置mv

CREATE MATERIALIZED VIEW app_logs.nginx_gw_log_mv TO app_logs.nginx_gw_log AS
SELECT timestamp,server_addr,remote_addr,time_sec,method,request_url,status,upstream_name,http_user_agent,upstream_addr,trace_id,upstream_status,upstream_response_time,toInt32(multiply(request_time, 1000)) as request_time,host
FROM app_logs.nginx_gw_log_kafka;

这里做了一个类型转换,因为nginx,request-time 单位是s,我想最终呈现在grafana 中是ms,所以这里做了转换,当然grafana中也可以做

上面都配置完了之后可以先验证下,保证数据最终到ck,如果有问题,需要再每个节点调试,比如先调试nginx->rsyslog ,可以先不配置kafka 输出,配置为console或者文件输出都可以,具体这里就不写了

grafana

{"annotations": {"list": [{"builtIn": 1,"datasource": {"type": "grafana","uid": "-- Grafana --"},"enable": true,"hide": true,"iconColor": "rgba(0, 211, 255, 1)","name": "Annotations & Alerts","target": {"limit": 100,"matchAny": false,"tags": [],"type": "dashboard"},"type": "dashboard"}]},"editable": true,"fiscalYearStartMonth": 0,"graphTooltip": 0,"id": 19,"links": [],"liveNow": false,"panels": [{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 0,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "auto","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 0},"id": 2,"options": {"legend": {"calcs": [],"displayMode": "list","placement": "bottom","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT time_sec as a, count() as num FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime )\r\ngroup by a order by a desc ;\r\n","refId": "A","selectedFormat": 4}],"title": "qps","type": "timeseries"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 0,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "auto","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 0},"id": 3,"options": {"legend": {"calcs": [],"displayMode": "list","placement": "bottom","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT time_sec as a, toInt32(quantile(0.95)(request_time))  as num FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime )\r\ngroup by a order by a desc ;","refId": "p95","selectedFormat": 4},{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"hide": false,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT time_sec as a, toInt32(quantile(0.99)(request_time))  as num FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime )\r\ngroup by a order by a desc ;","refId": "p99","selectedFormat": 4}],"title": "响应时间统计","type": "timeseries"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"custom": {"align": "auto","displayMode": "auto","inspect": false},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 9},"id": 4,"options": {"footer": {"fields": "","reducer": ["sum"],"show": false},"showHeader": true},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT request_time as k,request_url,trace_id  FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime )\r\n order by k desc limit 10;\r\n","refId": "A","selectedFormat": 4}],"title": "最耗时","type": "table"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"custom": {"align": "auto","displayMode": "auto","inspect": false},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 9},"id": 5,"options": {"footer": {"fields": "","reducer": ["sum"],"show": false},"showHeader": true},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT request_url, count() as num FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime )\r\ngroup by request_url order by request_url desc ;","refId": "A","selectedFormat": 4}],"title": "接口请求数量","type": "table"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"custom": {"align": "auto","displayMode": "auto","inspect": false},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 18},"id": 6,"options": {"footer": {"fields": "","reducer": ["sum"],"show": false},"showHeader": true},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT DISTINCT host  FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime );\r\n","refId": "A","selectedFormat": 4}],"title": "upstream","type": "table"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"custom": {"align": "auto","displayMode": "auto","inspect": false},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 18},"id": 8,"options": {"footer": {"fields": "","reducer": ["sum"],"show": false},"showHeader": true},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT  upstream_status,count() as num  FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime ) group by upstream_status;\r\n","refId": "A","selectedFormat": 4}],"title": "upstream","type": "table"},{"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"fieldConfig": {"defaults": {"mappings": [],"thresholds": {"mode": "percentage","steps": [{"color": "green","value": null},{"color": "orange","value": 70},{"color": "red","value": 85}]}},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 27},"id": 7,"options": {"orientation": "auto","reduceOptions": {"calcs": ["lastNotNull"],"fields": "","values": false},"showThresholdLabels": false,"showThresholdMarkers": true},"pluginVersion": "9.1.1","targets": [{"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"format": 1,"meta": {"builderOptions": {"database": "app_logs","fields": [],"filters": [{"condition": "AND","filterType": "custom","key": "timestamp","operator": "WITH IN DASHBOARD TIME RANGE","restrictToFields": [{"label": "timestamp","name": "timestamp","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"},{"label": "startTime","name": "startTime","picklistValues": [],"type": "DateTime64(3, 'Asia/Shanghai')"}],"type": "datetime"}],"groupBy": [],"limit": 100,"metrics": [{"aggregation": "count","field": ""}],"mode": "list","orderBy": [],"table": "tk_wx_control_req_kafka","timeField": "timestamp","timeFieldType": "DateTime64(3, 'Asia/Shanghai')"}},"queryType": "sql","rawSql": "SELECT count()  FROM \"app_logs\".${table_name} where ( timestamp  >= $__fromTime AND timestamp <= $__toTime );\r\n","refId": "A","selectedFormat": 4}],"title": "请求总数","type": "gauge"}],"schemaVersion": 37,"style": "dark","tags": [],"templating": {"list": [{"current": {"selected": false,"text": "nginx_gw_log","value": "nginx_gw_log"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"definition": "show  tables from app_logs where name = 'nginx_gw_log' ","hide": 0,"includeAll": false,"label": "table_name","multi": false,"name": "table_name","options": [],"query": "show  tables from app_logs where name = 'nginx_gw_log' ","refresh": 1,"regex": "","skipUrlSync": false,"sort": 0,"type": "query"},{"current": {"selected": false,"text": "ClickHouse_1.178","value": "ClickHouse_1.178"},"hide": 0,"includeAll": false,"label": "datasource","multi": false,"name": "datasource","options": [],"query": "grafana-clickhouse-datasource","queryValue": "","refresh": 1,"regex": "","skipUrlSync": false,"type": "datasource"},{"current": {"selected": true,"text": "atscontrol","value": "atscontrol"},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"definition": "select DISTINCT upstream_name from app_logs.nginx_gw_log","hide": 0,"includeAll": false,"label": "upstream_name","multi": false,"name": "upstream_name","options": [],"query": "select DISTINCT upstream_name from app_logs.nginx_gw_log","refresh": 2,"regex": "","skipUrlSync": false,"sort": 0,"type": "query"},{"current": {"isNone": true,"selected": false,"text": "None","value": ""},"datasource": {"type": "grafana-clickhouse-datasource","uid": "${datasource}"},"definition": "select DISTINCT nginx_host from app_logs.nginx_gw_log where upstream_name = \"$upstream_name\"","hide": 0,"includeAll": false,"label": "nginx_host","multi": false,"name": "nginx_host","options": [],"query": "select DISTINCT nginx_host from app_logs.nginx_gw_log where upstream_name = \"$upstream_name\"","refresh": 1,"regex": "","skipUrlSync": false,"sort": 0,"type": "query"}]},"time": {"from": "now-5m","to": "now"},"timepicker": {},"timezone": "","title": "nginx_gw","uid": "lZrbSYOIkA","version": 2,"weekStart": ""
}

最终呈现效果

在这里插入图片描述

隐患点

  • clickhouse 本身查询qps 就不高,如果数据量很大可以考虑集群或者其他的存储,doris、es等等
  • 不知道nginx+rsyslog 对性能有多少影响,目前测试单机nginx大几千的qps 都没啥问题

有其他更好方案的小伙伴留言哦

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/591343.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

跨境电商代采是什么?怎么做代采网站?

跨境电商独立站就是跨境电商自行搭建的销售网站&#xff0c;服务器、域名都是自主购买的&#xff0c;并由跨境电商独立运营与营销推广。 近些年来&#xff0c;各类第三方电商平台虽然流量大&#xff0c;但是随着进驻电商数量的增加&#xff0c;流量竞争也愈发激烈&#xff0c;…

雷达遮挡检测综述

1 概述 雷达&#xff08;毫米波、激光&#xff09;的遮挡是实际项目中比较常见的现象&#xff0c;优秀的算法应当能够及时、准确地检测出雷达是否被遮挡&#xff0c;以及遮挡的严重程度&#xff0c;然后将故障信息发送给诊断系统&#xff0c;并在仪表盘上显示&#xff0c;如…

win系统微软输入法踩坑之输入法

例如&#xff1a;字母间距变宽 或者打字总是繁体等等 字母变宽是因为快捷键误触切换成了全角字符。。 立马打开输入法设置界面进行相关设置&#xff08;你要解决的输入法问题都可以在这里得到解决&#xff09;&#xff1a;

LED恒流驱动芯片:700V高压线性恒流选型一览表

LED恒流驱动芯片是一种专门用于LED照明产品的电子元件&#xff0c;它能够实现LED的恒流驱动&#xff0c;从而保证LED灯具在工作过程中稳定的亮度和电流输出。其中&#xff0c;700V高压线性恒流是LED恒流驱动芯片的一个重要特性&#xff0c;下面就让我们来详细了解一下。 SM2253…

Apple Unity Plugins 接入GameCenter 崩溃解决方案

目录 问题问题原因解决方案可直接使用的UnityPlugins 问题 调用 GKLocalPlayer.Local.FetchItems() 程序崩溃&#xff0c;报错&#xff1a;Thread 1: EXC_BAD_ACCESS (code257, address0x8000000000000002) 启动崩溃&#xff0c;报错&#xff1a;Library not loaded: rpath/Ap…

新年新计划,羊大师教你如何实现个人目标与成长

新年新计划&#xff0c;羊大师教你如何实现个人目标与成长 新的一年已经到来&#xff0c;这是一个神奇的时刻&#xff0c;一个全新的开始&#xff0c;也是实现自己目标与成长的最佳时机。在这个瞬息万变的世界中&#xff0c;我们总是被忙碌的生活所迷失&#xff0c;然而我们需…

2023年度回顾:怿星科技的转型与创新

岁月不居&#xff0c;时节如流。随着2023年的落幕&#xff0c;怿星科技在这一年中不仅实现了自身的转型&#xff0c;还在技术创新、产品研发、行业合作和人才培养等方面取得了显著的成就。这一年&#xff0c;怿星科技正式完成了从服务型公司向产品型公司的战略转变&#xff0c;…

为什么选择 IBM LSF?

IBM Spectrum Computing 推出了全面的软件定义基础架构解 决方案产品组合&#xff0c;从而优化资源利用率以缩短成果实现时间并 降低成本&#xff0c;以高效地交付 IT 服务。IBM Spectrum Computing 解决方案非常适合技术和 HPC 应用&#xff0c;旨在简化和加速高性能 仿真和分…

Windows本地如何部署Apache服务器搭配内网穿透实现无公网IP远程访问?

文章目录 前言1.Apache服务安装配置1.1 进入官网下载安装包1.2 Apache服务配置 2.安装cpolar内网穿透2.1 注册cpolar账号2.2 下载cpolar客户端 3. 获取远程桌面公网地址3.1 登录cpolar web ui管理界面3.2 创建公网地址 4. 固定公网地址 前言 Apache作为全球使用较高的Web服务器…

深度学习|3.6 激活函数 3.7 为什么需要非线性激活函数

激活函数 主要有sigmoid函数、tanh函数、relu函数和leaky relu函数 tanh函数相比sigmoid函数是具有优势的&#xff0c;因为tanh函数使得输出值的平均值为0&#xff0c;而sigmoid函数使得输出值的平均值为1/2&#xff0c;对下一层来说tanh输出的0更好进行处理。 激活函数tanh…

DIA数皆智能客户体验管理CEM获伊利“健康+AI”生态创新大奖

DIA数皆智能客户体验管理CEM获伊利“健康AI”生态创新大奖 数皆智能再获殊荣&#xff01; 北京&#xff0c;2023年12月26日 — 在全球瞩目的伊利集团“健康AI”生态创新大赛中&#xff0c;上海数皆智能技术有限公司大放异彩&#xff0c;其创新领先的“智能化客户体验管理CEM&a…

第19届楚天春晚在九省通衢大武汉闪亮登场

——中国明星后代女子歌舞团刘亦菲等兼任形象大使 2024年新年伊始&#xff0c;一场以繁荣中国传统文化为主旨的“楚天春晚”全国文旅活动在湖北武汉拉开帷幕&#xff01;以“文化强省&#xff0c;旅游大省”为神州特色的联合国世界品牌之都&#xff0c;在辞旧迎新的早春来临之…

kubeadm来快速搭建一个K8S集群

二进制搭建适合大集群&#xff0c;50台以下的主机 kubeadm更适合中下企业的业务集群 我们采用了二进制包搭建出的k8s集群&#xff0c;本次我们采用更为简单的kubeadm的方式来搭建k8s集群。 二进制的搭建更适合50台主机以上的大集群&#xff0c;kubeadm更适合中小型企业的集群…

RocketMQ 生产者源码分析:DefaultMQProducer、DefaultMQProducerImpl

&#x1f52d; 嗨&#xff0c;您好 &#x1f44b; 我是 vnjohn&#xff0c;在互联网企业担任 Java 开发&#xff0c;CSDN 优质创作者 &#x1f4d6; 推荐专栏&#xff1a;Spring、MySQL、Nacos、Java&#xff0c;后续其他专栏会持续优化更新迭代 &#x1f332;文章所在专栏&…

Python 资源大全中文版

文末有链接 资源列表 环境管理 管理 Python 版本和环境的工具 p&#xff1a;非常简单的交互式 Python 版本管理工具。 pyenv&#xff1a;简单的 Python 版本管理工具。 Vex&#xff1a;可以在虚拟环境中执行命令。 virtualenv&#xff1a;创建独立 Python 环境的工具。 …

量子体积高达14082!这家公司正推动量子技术普及化

&#xff08;图片来源&#xff1a;网络&#xff09; Quantum AI致力于普及量子计算技术&#xff0c;成立仅一年&#xff0c;其研发的量子体积&#xff08;由IBM提出一个衡量量子计算机性能和错误率的专用指标&#xff09;已达到惊人的14082。 Quantum AI是Finlay MacKenzie和…

学习Go语言Web框架Gee总结--http.Handler(一)

学习Go语言Web框架Gee总结--http.Handler http-base/go.modhttp-base/main.gohttp-base/gee/gee.gohttp-base/gee/go.mod 网站学习来源&#xff1a;Gee 代码目录结构&#xff1a; http-base/go.mod //指定当前模块的名称为 "example" module example//指定当前模…

谷歌AI模型Gemini被指演示视频造假 /深圳园区推出鸿蒙工程师租房优惠 |魔法半周报

我有魔法✨为你劈开信息大海❗ 高效获取AIGC的热门事件&#x1f525;&#xff0c;更新AIGC的最新动态&#xff0c;生成相应的魔法简报&#xff0c;节省阅读时间&#x1f47b; &#x1f525;资讯预览 谷歌AI模型Gemini被指演示视频造假&#xff0c;AI“神话”成“笑话” 深圳园…

TCP/IP的网络层(即IP层)之IP地址和网络掩码,在视频监控系统中的配置和应用

在给客户讲解我们的AS-V1000视频监控平台的时候&#xff0c;有的客户经常会配置错误IP地址的掩码和网关&#xff0c;导致出现一些网路问题。而在视频监控系统中&#xff0c;IP地址和子网掩码是用于标识网络中设备的重要标识符。IP地址被用来唯一地标识一个网络设备&#xff0c;…

Docker:部署若依前后端分离版

Docker&#xff1a;部署若依前后端分离版 1. 停止天翼云上的原来跑的若依项目2. 停止腾讯云上的若依项目3. 使用Docker部署3.1 天翼云数据库&Redis3.1.1 部署数据库3.1.2 部署Redis数据库3.1.1 部署Nginx(这里被天翼云坑了换的腾讯云运行nginx) 3.2 腾讯云部署后端&前端…