一、映射本地告警文件到docker-compose
1.1、skywalking告警-指标说明
# cat config/oal/core.oal
- service_resp_time #服务的响应时间
- service_sla #服务的http请求成功率SLA,比如99%等。
- service_cpm #表示每分钟的吞吐量.
- service_apdex : 应用性能指数是0.8是0.x
- service_percentile: 指定最近多少数据范围内的响应时间百分比,即p99, p95, p90, p75, p50在内的数据统计结果
- endpoint_relation_cpm #端点的每分钟的吞吐量
- endpoint_relation_resp_time #端点的响应时间
- endpoint_relation_sla #端点的http请求成功率SLA,比如99%等。
- endpoint_relation_percentile ##端点的最近多少数据范围内的响应时间百分比,即p99、 p95、 p90、 p75、p50在内的数据统计结果
1.2、准备相关文件
准备core.oal、alarm-settings.yml文件,并将其挂载到docker-compose容器
wget https://archive.apache.org/dist/skywalking/8.6.0/apache-skywalking-apm-es7-8.6.0.tar.gz
tar -xf apache-skywalking-apm-es7-8.6.0.tar.gz
cp apache-skywalking-apm-bin-es7/config/alarm-settings.yml /apps/skywalking-docker-compose
cp apache-skywalking-apm-bin-es7/config/oal/core.oal /apps/skywalking-docker-compose
[root@skywalking-docker-compose-01 skywalking-docker-compose]# ll -h total 24K drwxr-xr-x 2 root root 4.0K Oct 4 06:38 ./ drwxr-xr-x 4 root root 4.0K Oct 1 11:23 ../ -rw-r--r-- 1 root root 3.3K Oct 4 06:38 alarm-settings.yml -rwxr-xr-x 1 root root 5.1K Oct 4 06:38 core.oal* -rw-r--r-- 1 root root 1.1K Oct 1 10:22 docker-compose.yaml [root@skywalking-docker-compose-01 skywalking-docker-compose]#
1.3、停止docker-compose
docker-compose down
[root@skywalking-docker-compose-01 skywalking-docker-compose]# docker-compose down Stopping skywalking-ui ... done Stopping skywalking-oap ... done Stopping es7 ... done Removing skywalking-ui ... done Removing skywalking-oap ... done Removing es7 ... done Removing network skywalking-docker-compose_default [root@skywalking-docker-compose-01 skywalking-docker-compose]# [root@skywalking-docker-compose-01 skywalking-docker-compose]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@skywalking-docker-compose-01 skywalking-docker-compose]#
1.4、编辑docker-compose.yaml
[root@skywalking-docker-compose-01 skywalking-docker-compose]# vi docker-compose.yaml
[root@skywalking-docker-compose-01 skywalking-docker-compose]# cat docker-compose.yaml
version: '3.3' services: es7: image: elasticsearch:7.10.1 container_name: es7 ports: - 9200:9200 - 9300:9300 environment: - discovery.type=single-node #单机模式 - bootstrap.memory_lock=true #锁定物理内存地址 - "ES_JAVA_OPTS=-Xms1048m -Xmx1048m" #堆内存大小 - TZ=Asia/Shanghai ulimits: memlock: soft: -1 hard: -1 volumes: - /data/elasticsearch/data:/usr/share/elasticsearch/data skywalking-oap: image: apache/skywalking-oap-server:8.6.0-es7 container_name: skywalking-oap restart: always volumes: - ./core.oal:/skywalking/config/oal/core.oal - ./alarm-settings.yml:/skywalking/config/alarm-settings.yml depends_on: - es7 links: - es7 ports: - 11800:11800 - 12800:12800 environment: TZ: Asia/Shanghai SW_STORAGE: elasticsearch7 SW_STORAGE_ES_CLUSTER_NODES: es7:9200 skywalking-ui: image: apache/skywalking-ui:8.6.0 container_name: skywalking-ui restart: always depends_on: - skywalking-oap links: - skywalking-oap ports: - 8080:8080 environment: TZ: Asia/Shanghai SW_OAP_ADDRESS: skywalking-oap:12800
1.5、启动docker-compose
docker-compose up -d
[root@skywalking-docker-compose-01 skywalking-docker-compose]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@skywalking-docker-compose-01 skywalking-docker-compose]# docker-compose up -d Creating network "skywalking-docker-compose_default" with the default driver Creating es7 ... done Creating skywalking-oap ... done Creating skywalking-ui ... done [root@skywalking-docker-compose-01 skywalking-docker-compose]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c665206a3c0b apache/skywalking-ui:8.6.0 "bash docker-entrypo…" 9 seconds ago Up 7 seconds 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp skywalking-ui b4b9e3568a7b apache/skywalking-oap-server:8.6.0-es7 "bash docker-entrypo…" 9 seconds ago Up 8 seconds 0.0.0.0:11800->11800/tcp, :::11800->11800/tcp, 1234/tcp, 0.0.0.0:12800->12800/tcp, :::12800->12800/tcp skywalking-oap ce7014704924 elasticsearch:7.10.1 "/tini -- /usr/local…" 10 seconds ago Up 8 seconds 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp es7 [root@skywalking-docker-compose-01 skywalking-docker-compose]# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1338450/docker-prox tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN 1338075/docker-prox tcp 0 0 0.0.0.0:9300 0.0.0.0:* LISTEN 1338052/docker-prox tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 675/systemd-resolve tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 834/sshd: /usr/sbin tcp 0 0 0.0.0.0:11800 0.0.0.0:* LISTEN 1338247/docker-prox tcp 0 0 127.0.0.1:44857 0.0.0.0:* LISTEN 770/containerd tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 1335264/sshd: root@ tcp 0 0 127.0.0.1:6011 0.0.0.0:* LISTEN 1335684/sshd: root@ tcp 0 0 0.0.0.0:12800 0.0.0.0:* LISTEN 1338217/docker-prox tcp6 0 0 :::8080 :::* LISTEN 1338457/docker-prox tcp6 0 0 :::9200 :::* LISTEN 1338081/docker-prox tcp6 0 0 :::9300 :::* LISTEN 1338057/docker-prox tcp6 0 0 :::22 :::* LISTEN 834/sshd: /usr/sbin tcp6 0 0 :::11800 :::* LISTEN 1338254/docker-prox tcp6 0 0 ::1:6010 :::* LISTEN 1335264/sshd: root@ tcp6 0 0 ::1:6011 :::* LISTEN 1335684/sshd: root@ tcp6 0 0 :::12800 :::* LISTEN 1338223/docker-prox [root@skywalking-docker-compose-01 skywalking-docker-compose]#
二、配置skywalking 钉钉告警
2.1、skywalking 告警简单说明
#vim config/alarm-settings.yml
- rules: #定义rule规则
- service_cpm_rule: #唯一的规则名称,必须以_rule结尾
- metrics-name: service_cpm #指标名称
- op: ">" #操作符,>, >=, <, <=, ==
- threshold: 1 #指标阈值
- period: 2 #评估指标的间隔周期
- count: 1 #匹配成功多少次就会触发告警
- silence-period: 2 #触发告警后的静默时间
- message: dubbo-provider service_cpm 大于1了 #告警信息
2.2、自定义告警规则
[root@skywalking-docker-compose-01 skywalking-docker-compose]# vi alarm-settings.yml
[root@skywalking-docker-compose-01 skywalking-docker-compose]# cat alarm-settings.yml
rules: service_cpm_rule: metrics-name: service_cpm op: ">" threshold: 1 period: 1 count: 1 silence-period: 1 message: dubbo-provider的当前指标service_cpm,请求值大于5000了!!!! dingtalkHooks: textTemplate: |- { "msgtype": "text", "text": { "content": "Apache SkyWalking Alarm: \n %s." } } webhooks: - url: https://oapi.dingtalk.com/robot/send?access_token=abxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxc5d
2.3、钉钉加上告警关键字
2.4、重建docker-compose
[root@skywalking-docker-compose-01 skywalking-docker-compose]# docker-compose down Stopping skywalking-ui ... done Stopping skywalking-oap ... done Stopping es7 ... done Removing skywalking-ui ... done Removing skywalking-oap ... done Removing es7 ... done Removing network skywalking-docker-compose_default [root@skywalking-docker-compose-01 skywalking-docker-compose]# [root@skywalking-docker-compose-01 skywalking-docker-compose]# docker-compose up -d Creating network "skywalking-docker-compose_default" with the default driver Creating es7 ... done Creating skywalking-oap ... done Creating skywalking-ui ... done [root@skywalking-docker-compose-01 skywalking-docker-compose]#
2.5、测试告警
不断刷新页面,让其访问值超过1
skywalking server端也显示发送的告警信息
标签:compose,实现,0.0,告警,tcp,docker,root,skywalking From: https://www.cnblogs.com/cyh00001/p/16753736.html