Prometheus+Grafana 监控Tongweb7(by lqw)

文章目录

  • 1.准备工作
  • 2.Tongweb7部署
  • 3.Prometheus部署
  • 4.上传jar包并配置Tongweb7
  • 5.Prometheus配置
  • 6.安装和配置Grafana

1.准备工作

本次参考:Prometheus监控Tongweb容器

1.使用虚拟机ip:192.168.10.51(tongweb),192.168.10.52(Prometheus),192.168.10.8(Grafana ),其中51服务器确保9060,39081端口没有被占用,52服务器确保9090端口没有被占用,8服务器确保3000端口没有被占用,三台虚拟机均关闭防火墙。

2.使用的jar包:jmx_prometheus_javaagent-0.19.0.jar:jmx_prometheus_javaagent-0.19.0.jar下载链接

在这里插入图片描述

3.使用的jdk环境:jdk1.8(需配置jdk环境变量)

在这里插入图片描述
4.下载Grafana使用的仪表盘json文件:
TongWeb 面板,使用JMX Exporter采集数据

也可以新建一个json文件,复制粘贴以下内容:

{"__inputs": [{"name": "DS_PROMETHEUS","label": "Prometheus","description": "","type": "datasource","pluginId": "prometheus","pluginName": "Prometheus"}],"__elements": {},"__requires": [{"type": "panel","id": "gauge","name": "Gauge","version": ""},{"type": "grafana","id": "grafana","name": "Grafana","version": "10.0.1"},{"type": "datasource","id": "prometheus","name": "Prometheus","version": "1.0.0"},{"type": "panel","id": "stat","name": "Stat","version": ""},{"type": "panel","id": "table","name": "Table","version": ""},{"type": "panel","id": "timeseries","name": "Time series","version": ""}],"annotations": {"list": [{"builtIn": 1,"datasource": {"type": "datasource","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"}]},"description": "TongWeb 面板,使用JMX Exporter采集数据","editable": true,"fiscalYearStartMonth": 0,"gnetId": 19156,"graphTooltip": 0,"id": null,"links": [{"asDropdown": false,"icon": "external link","includeVars": false,"keepTime": false,"tags": [],"targetBlank": true,"title": "更新面板","tooltip": "","type": "link","url": "https://grafana.com/grafana/dashboards/19156"}],"liveNow": false,"panels": [{"collapsed": false,"datasource": {"type": "prometheus","uid": "fb65406e-39df-40f2-966c-9987082bdcfe"},"gridPos": {"h": 1,"w": 24,"x": 0,"y": 0},"id": 31,"panels": [],"repeat": "protocol","targets": [{"datasource": {"type": "prometheus","uid": "fb65406e-39df-40f2-966c-9987082bdcfe"},"refId": "A"}],"title": "监控信息","type": "row"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"description": "被监控服务是否处于运行状态,即该服务是否可达。当UP指标的值为1时,表示该服务正在运行,并且可以被访问,当UP指标的值为0时,则表示该服务不可达或处于停止状态。","fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"mappings": [{"options": {"0": {"color": "red","index": 1,"text": "未连通"},"1": {"color": "green","index": 0,"text": "连通"}},"type": "value"},{"options": {"match": "null","result": {"color": "red","index": 2,"text": "未连通"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},"overrides": []},"gridPos": {"h": 4,"w": 4,"x": 0,"y": 1},"id": 33,"options": {"colorMode": "value","graphMode": "area","justifyMode": "auto","orientation": "auto","reduceOptions": {"calcs": ["lastNotNull"],"fields": "","values": false},"text": {},"textMode": "auto"},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "up{instance=~\"$instance\"}","instant": true,"interval": "","legendFormat": "状态","refId": "A"}],"title": "运行状态","type": "stat"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"decimals": 2,"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "orange","value": 80}]},"unit": "percent"},"overrides": []},"gridPos": {"h": 4,"w": 5,"x": 4,"y": 1},"id": 17,"links": [],"maxDataPoints": 100,"options": {"orientation": "horizontal","reduceOptions": {"calcs": ["mean"],"fields": "","values": false},"showThresholdLabels": false,"showThresholdMarkers": true},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "jvm_memory_bytes_used{area='heap', instance=\"$instance\"}/jvm_memory_bytes_max{area='heap', instance=\"$instance\"}*100","format": "time_series","instant": true,"interval": "","intervalFactor": 1,"legendFormat": "","refId": "A"}],"title": "JVM内存使用率","type": "gauge"},{"datasource": {"type": "prometheus","uid": "$datasource"},"fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "none"},"overrides": []},"gridPos": {"h": 4,"w": 5,"x": 9,"y": 1},"id": 20,"links": [],"maxDataPoints": 100,"options": {"colorMode": "value","graphMode": "none","justifyMode": "auto","orientation": "horizontal","reduceOptions": {"calcs": ["mean"],"fields": "","values": false},"textMode": "auto"},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "sum(tongweb_manager_sessioncounter{instance=\"$instance\"})","format": "time_series","instant": true,"interval": "","intervalFactor": 1,"legendFormat": "","refId": "A"}],"title": "会话总个数","type": "stat"},{"datasource": {"type": "prometheus","uid": "$datasource"},"fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null}]},"unit": "none"},"overrides": []},"gridPos": {"h": 4,"w": 5,"x": 14,"y": 1},"id": 21,"links": [],"maxDataPoints": 100,"options": {"colorMode": "value","graphMode": "none","justifyMode": "auto","orientation": "horizontal","reduceOptions": {"calcs": ["mean"],"fields": "","values": false},"textMode": "auto"},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "sum(tongweb_manager_expiredsessions{instance=\"$instance\"}) ","format": "time_series","instant": true,"interval": "","intervalFactor": 1,"legendFormat": "","refId": "A"}],"title": "会话过期数","type": "stat"},{"datasource": {"type": "prometheus","uid": "$datasource"},"fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "none"},"overrides": []},"gridPos": {"h": 4,"w": 5,"x": 19,"y": 1},"id": 19,"links": [],"maxDataPoints": 100,"options": {"colorMode": "value","graphMode": "none","justifyMode": "auto","orientation": "horizontal","reduceOptions": {"calcs": ["mean"],"fields": "","values": false},"textMode": "auto"},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "sum(tongweb_manager_sessioncounter{ instance=\"$instance\"} - tongweb_manager_expiredsessions{instance=\"$instance\"})","format": "time_series","instant": true,"interval": "","intervalFactor": 1,"legendFormat": "","refId": "A"}],"title": "当前会话计数","type": "stat"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "thresholds"},"custom": {"align": "auto","cellOptions": {"type": "auto"},"inspect": false},"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"min": 0,"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null}]},"unit": "none"},"overrides": [{"matcher": {"id": "byName","options": "线程池使用率*"},"properties": [{"id": "color","value": {"mode": "continuous-GrYlRd"}},{"id": "custom.cellOptions","value": {"mode": "gradient","type": "gauge"}},{"id": "unit","value": "percent"},{"id": "decimals","value": 1},{"id": "min","value": -1},{"id": "thresholds","value": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]}},{"id": "max","value": 100}]},{"matcher": {"id": "byName","options": "http通道"},"properties": [{"id": "custom.width","value": 200}]},{"matcher": {"id": "byName","options": "最大线程数"},"properties": [{"id": "custom.width","value": 90}]},{"matcher": {"id": "byName","options": "初始线程数"},"properties": [{"id": "custom.width","value": 90}]},{"matcher": {"id": "byName","options": "线程优先级"},"properties": [{"id": "custom.width","value": 90}]},{"matcher": {"id": "byName","options": "等待队列"},"properties": [{"id": "custom.width","value": 90}]}]},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 5},"id": 14,"links": [],"maxDataPoints": 100,"options": {"cellHeight": "sm","footer": {"countRows": false,"fields": "","reducer": ["sum"],"show": false},"showHeader": true,"sortBy": [{"desc": true,"displayName": "线程池使用率"}]},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_maxthreads{ instance=\"$instance\"}","format": "table","hide": false,"instant": true,"interval": "","intervalFactor": 1,"legendFormat": "{{name}}-最大线程数","range": false,"refId": "A"},{"datasource": {"type": "prometheus","uid": "$datasource"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_minsparethreads{instance=\"$instance\"}","format": "table","hide": false,"instant": true,"legendFormat": "{{name}}-使用线程数","range": false,"refId": "B"},{"datasource": {"type": "prometheus","uid": "$datasource"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_connectioncount{ instance=\"$instance\"}","format": "table","hide": false,"instant": true,"legendFormat": "{{name}}","range": false,"refId": "C"},{"datasource": {"type": "prometheus","uid": "$datasource"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_connectioncount{ instance=\"$instance\"}/tongweb_threadpool_maxthreads{ instance=\"$instance\"}*100","format": "table","hide": false,"instant": true,"range": false,"refId": "D"},{"datasource": {"type": "prometheus","uid": "$datasource"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_threadpriority{instance=\"$instance\"}","format": "table","hide": false,"instant": true,"range": false,"refId": "E"},{"datasource": {"type": "prometheus","uid": "$datasource"},"editorMode": "code","exemplar": false,"expr": "tongweb_threadpool_backlog{instance=\"$instance\"}","format": "table","hide": false,"instant": true,"range": false,"refId": "F"}],"title": "线程池信息","transformations": [{"id": "filterFieldsByName","options": {"include": {"pattern": "/^Value #[A-Z]|^name$/"}}},{"id": "merge","options": {}},{"id": "organize","options": {"excludeByName": {},"indexByName": {},"renameByName": {"Value #A": "最大线程数","Value #B": "初始线程数","Value #C": "正在执行任务的线程数*","Value #D": "线程池使用率*","Value #E": "线程优先级","Value #F": "等待队列","name": "http通道"}}},{"id": "groupBy","options": {"fields": {"Value #E": {"aggregations": [],"operation": "groupby"},"http通道": {"aggregations": [],"operation": "groupby"},"初始线程数": {"aggregations": ["lastNotNull"],"operation": "groupby"},"最大线程数": {"aggregations": [],"operation": "groupby"},"正在执行任务的线程数": {"aggregations": [],"operation": "groupby"},"正在执行任务的线程数*": {"aggregations": [],"operation": "groupby"},"等待队列": {"aggregations": [],"operation": "groupby"},"线程优先级": {"aggregations": [],"operation": "groupby"},"线程池使用率": {"aggregations": [],"operation": "groupby"},"线程池使用率*": {"aggregations": [],"operation": "groupby"}}}}],"type": "table"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 6,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 1,"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}]},"unit": "percent"},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 5},"id": 40,"options": {"legend": {"calcs": [],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","expr": "tongweb_threadpool_connectioncount{ instance=\"$instance\"}/tongweb_threadpool_maxthreads{ instance=\"$instance\"}*100","instant": false,"legendFormat": "{{name}}","range": true,"refId": "A"}],"title": "线程池使用率","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "continuous-BlPu"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 14,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineStyle": {"fill": "solid"},"lineWidth": 1,"pointSize": 1,"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": 14},"id": 39,"links": [],"maxDataPoints": 100,"options": {"legend": {"calcs": [],"displayMode": "list","placement": "bottom","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "jvm_memory_bytes_used{area='heap', instance=\"$instance\"}/jvm_memory_bytes_max{area='heap', instance=\"$instance\"}*100","format": "time_series","instant": false,"interval": "","intervalFactor": 1,"legendFormat": "内存使用率","range": true,"refId": "A"}],"title": "JVM内存使用率","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 6,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 1,"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": 14},"id": 41,"options": {"legend": {"calcs": [],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","expr": "increase(tongweb_requestprocessor_errorcount{instance=\"$instance\"}[5m])","instant": false,"legendFormat": "{{worker}}-{{name}}","range": true,"refId": "A"}],"title": "近5分钟错误增长数","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 8,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 1,"scaleDistribution": {"type": "linear"},"showPoints": "auto","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "ms"},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 23},"id": 35,"links": [],"maxDataPoints": 100,"options": {"legend": {"calcs": [],"displayMode": "list","placement": "right","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "sum(increase(tongweb_requestprocessor_processingtime{instance=\"$instance\"}[5m])) by (worker) / (count(tongweb_requestprocessor_processingtime{instance=\"$instance\"}) by (worker)+0.01) ","format": "time_series","instant": false,"interval": "","intervalFactor": 1,"legendFormat": "{{worker}}","range": true,"refId": "A"}],"title": "平均响应时长","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 11,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 1,"scaleDistribution": {"type": "linear"},"showPoints": "auto","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"decimals": 2,"mappings": [{"options": {"match": "null","result": {"text": "N/A"}},"type": "special"}],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "orange","value": 80}]},"unit": "percent"},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 23},"id": 37,"links": [],"maxDataPoints": 100,"options": {"legend": {"calcs": [],"displayMode": "list","placement": "bottom","showLegend": true},"tooltip": {"mode": "single","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "jvm_memory_pool_bytes_used{ instance=\"$instance\", pool!=\"Metaspace\"}/jvm_memory_pool_bytes_max{ instance=\"$instance\", pool!=\"Metaspace\"}*100","format": "time_series","instant": false,"interval": "","intervalFactor": 1,"legendFormat": "{{pool}}","range": true,"refId": "A"}],"title": "JVM内存池使用率","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 10,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "never","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"decimals": 0,"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "none"},"overrides": [{"matcher": {"id": "byValue","options": {"op": "gte","reducer": "allIsZero","value": 0}},"properties": [{"id": "custom.hideFrom","value": {"legend": true,"tooltip": true,"viz": false}}]}]},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 32},"id": 23,"links": [],"options": {"legend": {"calcs": [],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "multi","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": false,"expr": "topk(5, tongweb_globalrequestprocessor_requestcount{ instance=\"$instance\"})","format": "time_series","instant": false,"interval": "","intervalFactor": 1,"legendFormat": "{{name}} ","range": true,"refId": "A"}],"title": "请求计数TOP5","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 10,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "never","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"decimals": 0,"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "short"},"overrides": [{"matcher": {"id": "byValue","options": {"op": "gte","reducer": "allIsZero","value": 0}},"properties": [{"id": "custom.hideFrom","value": {"legend": true,"tooltip": true,"viz": false}}]}]},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 32},"id": 24,"links": [],"options": {"legend": {"calcs": [],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "multi","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "topk(5,tongweb_requestprocessor_errorcount{ instance=\"$instance\"})","format": "time_series","interval": "","intervalFactor": 1,"legendFormat": "{{worker}} ","range": true,"refId": "A"}],"title": "错误计数TOP5","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 10,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "never","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "decbytes"},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 0,"y": 41},"id": 2,"links": [],"options": {"legend": {"calcs": [],"displayMode": "list","placement": "right","showLegend": true},"tooltip": {"mode": "multi","sort": "none"}},"pluginVersion": "10.0.1","repeatDirection": "h","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "increase(tongweb_globalrequestprocessor_bytesreceived{ instance=\"$instance\"}[$__interval])","format": "time_series","interval": "60s","intervalFactor": 1,"legendFormat": "Received {{name}}","range": true,"refId": "A"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "increase(tongweb_globalrequestprocessor_bytessent{ instance=\"$instance\"}[$__interval])","format": "time_series","interval": "60s","intervalFactor": 1,"legendFormat": "Sent {{name}}","range": true,"refId": "B"}],"title": "发送/接收流量","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "tomcat_requestcount_total是Tomcat服务器的一个请求计数器,它记录了所有已处理的请求总数。 在Tomcat服务器中,每个客户端请求都会被处理为一个请求,在处理请求期间,服务器会从连接中读取数据、解析数据、执行应用逻辑,并返回响应。每当Tomcat服务器成功处理一个请求时,其tomcat_requestcount_total指标就会相应地增加。监控和分析该指标可以帮助管理员和开发人员更好地了解Tomcat服务器的整体负载情况和活动水平,对于性能优化和故障排除都具有一定的价值。此外,该指标也可以通过与其他指标如tomcat_bytesreceived_total和tomcat_bytessent_total等结合使用,来监测网络流量和请求响应时间等性能指标,以进一步优化Tomcat服务器的配置和性能。","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 10,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "never","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"decimals": 0,"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "short"},"overrides": []},"gridPos": {"h": 9,"w": 12,"x": 12,"y": 41},"id": 4,"links": [],"options": {"legend": {"calcs": ["lastNotNull","max","min"],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "multi","sort": "none"}},"pluginVersion": "10.0.1","repeatDirection": "h","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "increase(tongweb_globalrequestprocessor_requestcount{ instance=\"$instance\"}[5m])","format": "time_series","interval": "60s","intervalFactor": 1,"legendFormat": "Request {{name}}","range": true,"refId": "A"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "increase(tongweb_globalrequestprocessor_errorcount{ instance=\"$instance\"}[5m])","format": "time_series","interval": "60s","intervalFactor": 1,"legendFormat": "Error  {{name}}","range": true,"refId": "B"}],"title": "请求计数/错误计数","type": "timeseries"},{"datasource": {"type": "prometheus","uid": "$datasource"},"description": "","fieldConfig": {"defaults": {"color": {"mode": "palette-classic"},"custom": {"axisCenteredZero": false,"axisColorMode": "text","axisLabel": "","axisPlacement": "auto","barAlignment": 0,"drawStyle": "line","fillOpacity": 10,"gradientMode": "none","hideFrom": {"legend": false,"tooltip": false,"viz": false},"lineInterpolation": "linear","lineWidth": 1,"pointSize": 5,"scaleDistribution": {"type": "linear"},"showPoints": "never","spanNulls": false,"stacking": {"group": "A","mode": "none"},"thresholdsStyle": {"mode": "off"}},"decimals": 0,"mappings": [],"thresholds": {"mode": "absolute","steps": [{"color": "green","value": null},{"color": "red","value": 80}]},"unit": "none"},"overrides": [{"__systemRef": "hideSeriesFrom","matcher": {"id": "byNames","options": {"mode": "exclude","names": ["New"],"prefix": "All except:","readOnly": true}},"properties": [{"id": "custom.hideFrom","value": {"legend": false,"tooltip": false,"viz": true}}]}]},"gridPos": {"h": 8,"w": 24,"x": 0,"y": 50},"id": 5,"links": [],"options": {"legend": {"calcs": ["lastNotNull","max","min"],"displayMode": "table","placement": "right","showLegend": true},"tooltip": {"mode": "multi","sort": "none"}},"pluginVersion": "10.0.1","targets": [{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","exemplar": true,"expr": "sum(increase(tongweb_manager_sessioncounter{ instance=\"$instance\"}[5m])) by (instance)","format": "time_series","hide": false,"interval": "60s","intervalFactor": 1,"legendFormat": "New","range": true,"refId": "A"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","expr": "sum(increase(tongweb_manager_expiredsessions{ instance=\"$instance\"}[5m])) by (instance)","format": "time_series","hide": false,"interval": "60s","intervalFactor": 1,"legendFormat": "Expired","range": true,"refId": "B"},{"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"editorMode": "code","expr": "sum(increase(tongweb_manager_rejectedsessions{ instance=\"$instance\"}[5m])) by (instance)","format": "time_series","hide": false,"interval": "60s","intervalFactor": 1,"legendFormat": "Rejected","range": true,"refId": "C"}],"title": "会话计数统计","type": "timeseries"}],"refresh": "5s","schemaVersion": 38,"style": "dark","tags": ["Tomcat8"],"templating": {"list": [{"current": {"selected": false,"text": "Prometheus","value": "Prometheus"},"hide": 0,"includeAll": false,"multi": false,"name": "datasource","options": [],"query": "prometheus","queryValue": "","refresh": 1,"regex": "","skipUrlSync": false,"type": "datasource"},{"allValue": ".*","current": {},"datasource": {"type": "prometheus","uid": "${DS_PROMETHEUS}"},"definition": "label_values(jvm_info{},instance)","hide": 0,"includeAll": false,"label": "Instance","multi": false,"name": "instance","options": [],"query": {"query": "label_values(jvm_info{},instance)","refId": "PrometheusVariableQueryEditor-VariableQuery"},"refresh": 2,"regex": "","skipUrlSync": false,"sort": 1,"tagValuesQuery": "","tagsQuery": "","type": "query","useTags": false}]},"time": {"from": "now-15m","to": "now"},"timepicker": {"refresh_intervals": ["5s","10s","30s","1m","5m","15m"],"time_options": ["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone": "","title": "TongWeb_dashboard","uid": "tongweb","version": 71,"weekStart": ""
}

5.tw7的安装包和授权,其中tw7使用的安装包为TongWeb7.0.4.9_M3_Enterprise_Linux.tar.gz。

2.Tongweb7部署

参考:TongWeb7-绿色版安装及启动停止和控制台访问

3.Prometheus部署

参考:一篇文章搞定Prometheus普罗米修斯监控系统的部署

4.上传jar包并配置Tongweb7

把下载好的jar包放入到Tongweb7安装目录的bin目录下
在这里插入图片描述
新建一個config.yaml
在这里插入图片描述
vi 这个文件,复制粘贴以下内容(注意缩进):

wercaseOutputLabelNames: true
lowercaseOutputName: true
whitelistObjectNames: ["java.lang:type=OperatingSystem", "TONGWEB:*","config:*"]
blacklistObjectNames: []
rules:- pattern: ".*"

以下是配置内容的用途
在这里插入图片描述

TongWeb安装目录/bin目录下,修改external.vmoptions文件,在#jvm_options 后添加javaagent参数
在这里插入图片描述
參考配置:

-javaagent:"/opt/TongWeb7.0.4.9_M3_Enterprise_Linux/bin/jmx_prometheus_javaagent-0.19.0.jar=39081:/opt/TongWeb7.0.4.9_M3_Enterprise_Linux/bin/config.yaml"

备注:
1.这里要使用jmx_prometheus_javaagent-0.19.0.jar和config.yaml所在目录,我的是在/opt/TongWeb7.0.4.9_M3_Enterprise_Linux/bin。
2.配置在#jvm_options下面,如下图所示:
在这里插入图片描述

3.除了这个配置,不能有#等其他多余字符串(#在这个配置文件里不是注释修饰符)。
4.如果改错了,会导致tongweb启动失败,所以万一启动失败了,请直接删了重新配。

配置后重启tongweb,然后访问服务器ip:39081/metrics,看看有没有数据
在这里插入图片描述

5.Prometheus配置

配置prometheus.yml:

在这里插入图片描述

在这里插入图片描述

配置参考(注意缩进,192.168.10.51和39081分别对应的是tongweb这边的端口和ip):

static_configs:- targets: ["localhost:9090"]- job_name: tongwebstatic_configs:- targets: ['192.168.10.51:39081']labels:instance: 192.168.10.51

下面是我本地的配置文件,自行删除不需要的部分:

global:scrape_interval: 15s        # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s    # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093rule_files:# - "first_rules.yml"# - "second_rules.yml"scrape_configs:- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]- job_name: 'Prometheus19'metrics_path: /metricsstatic_configs:- targets:- rdsrelabel_configs:- source_labels: [__address__]target_label: __param_target- source_labels: [__param_target]target_label: instance- target_label: __address__replacement: 192.168.10.19:9098- job_name: 'Prometheus20'metrics_path: /metricsstatic_configs:- targets:- rdsrelabel_configs:- source_labels: [__address__]target_label: __param_target- source_labels: [__param_target]target_label: instance- target_label: __address__replacement: 192.168.10.20:9098- job_name: "tongweb"static_configs:- targets: ['192.168.10.51:39081']labels:instance: 192.168.10.51

修改完启动Prometheus

cd /usr/local/promethues/./prometheus --config.file="/usr/local/promethues/prometheus.yml" &ps ef |grep promethues

访问服务器ip:9090/targets?search=,点击status,target,就可以看到我们配置的信息:
在这里插入图片描述

6.安装和配置Grafana

Grafana下载地址

在这里插入图片描述
上图的话,安装后用 systemctl start grafana-server 启动,会方便一些。

或者用这个也行,这个的话后面启动要用脚本启动(本文使用这种方式)。
在这里插入图片描述
解压一下安装包

tar -vxf grafana-enterprise-10.3.1.linux-amd64.tar.gz

启动:
cd 到安装目录bin目录,执行./grafana-server,然后访问服务器ip:3000

注意:默认账号密码为:
账号:admin
密码:admin如果你想卸载,可以关闭服务(直接pkill grafana-server也行),直接删除安装目录,然后删除对应配置```xml
sudo rm -rf /var/lib/grafana
sudo rm -rf /var/log/grafana
sudo rm -rf /etc/grafana
sudo rm -rf /etc/grafana/grafana.ini
sudo rm -rf  /var/lib/grafana/grafana.db

在这里插入图片描述

通常情况下,Grafana 服务的配置文件位于 /etc/grafana/grafana.ini,日志通常存储在 /var/log/grafana,而数据库默认位于 /var/lib/grafana/grafana.db。您可能需要查看这些文件以进行故障排查或者进行配置更改。记得在修改配置文件之后重启 Grafana 服务使更改生效。

Grafana只用于展示数据,需要配置Prometheus数据源。

在这里插入图片描述

在这里插入图片描述
写你的prometheus的url,带上端口号9090:
在这里插入图片描述

点击下方的sava&test,有下图的提示说明成功:
在这里插入图片描述
然后回到home,找到Create your first dashboard:
在这里插入图片描述
点击import a dashboard:
在这里插入图片描述
上传之前下载的json文件在这里插入图片描述
上传后选择一下prometheus:
在这里插入图片描述
然后点击import,仪表盘就出现了:
在这里插入图片描述

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

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

相关文章

vue iframe实现父页面实时调用子页面方法和内容

父页面标签添加鼠标按下事件 父页方法中建立iframe通信 实时调用子页面方法 实时更改子页面文本内容

Ubuntu上搭建TFTP服务

Ubuntu上搭建TFTP服务 TFTP服务简介搭建TFTP服务安装TFTP服务修改配置文件 重启服务 TFTP服务简介 TFTP是一个基于UDP协议实现的用于在客户机和服务器之间进行简单文件传输的协议,适用于开销不大、不复杂的应用场合。TFTP协议专门为小文件传输而设计,只…

[C语言]——操作符详解

目录 一.操作符的分类 二.二进制和进制转换 1.二进制转十进制 2.二进制转八进制和十六进制 2.1二进制转八进制 2.2二进制转十六进制 三.原码、反码、补码 四.移位操作符 1.左移操作符 2.右移操作符 五.位操作符:&、|、^、~ 练习1:编写代码实…

腾讯云GPU云服务器简介_GPU服务器购买指南_GPU云服务器操作

腾讯云GPU服务器是提供GPU算力的弹性计算服务,腾讯云GPU服务器具有超强的并行计算能力,可用于深度学习训练、科学计算、图形图像处理、视频编解码等场景,腾讯云百科txybk.com整理腾讯云GPU服务器租用价格表、GPU实例优势、GPU解决方案、GPU软…

Spring Boot Actuator介绍

大家在yaml中经常见到的这个配置 management: endpoints: web: exposure: #该配置线上需要去掉,会有未授权访问漏洞 include: "*" 他就是Actuator! 一、什么是 Actuator Spring Boot Actuator 模块提供了生产级别…

漏洞挖掘技术综述与人工智能应用探索:从静态分析到深度学习,跨项目挑战与未来机遇

在网络安全和软件工程领域中,将机器学习应用于源代码漏洞挖掘是一种先进的自动化方法。该过程遵循典型的监督学习框架,并可细化为以下几个关键步骤: 数据预处理: 源代码解析与清理:首先对源代码进行文本解析&#xff…

zookeeper底层细节

zk 临时节点和watch机制实现注册中心自动注册和发现,数据都在内存,nio 多线程模型; cp注重一致性,数据不一致时集群不可用 事务请求处理方式 1.all事务由唯一服务器处理 2.将客户端事务请求转成proposal分发follower 3.等待半…

异常 --java学习笔记

异常 异常就是代表程序出现的问题 当一个方法出现问题,这个方法内部就会把这个问题的信息封装成一个异常对象,然后把这个异常对象抛给jvm虚拟机,jvm收到之后会先把出问题的程序先停下来,然后再把这个异常对象打印出来&#xff0c…

python之jsonpath的使用

文章目录 介绍安装语法语法规则举例说明 在 python 中使用获取所有结构所有子节点的作者获取所有子孙节点获取所有价格取出第三本书的所有信息取出价格大于70块的所有书本从mongodb 中取数据的示例 介绍 JSONPath能在复杂的JSON数据中 查找和提取所需的信息,它是一…

JavaMySQL高级一(下)

目录 1.常用函数 1.字符串函数 2.时间日期函数 3.聚合函数 4.数学函数 2.分布查询 3.子查询基础 1.简单子查询 1.常用函数 在程序开发过程中,除了简单的数据查询,还有基于已数据进行数据的统计分析计算等需求。因此,在SQL中将一…

电感回路中的电阻突然变大会怎样

大家好,我是砖一。 我们经常会看到这样一个电路,电感和电阻搭配在一块,加上5v供电,如果电感回路中的电阻突然变大会怎样? 假设电感L1100uH,电阻R110Ω。 图1 串入电感图 1,由开关状态分析电路…

【C语言】基本语法知识C语言函数操作符详解

主页:醋溜马桶圈-CSDN博客 专栏:C语言_醋溜马桶圈的博客-CSDN博客 gitee:mnxcc (mnxcc) - Gitee.com 目录 1.基本语法 1.1 代码解释 1.1.1 main()主函数 1.1.2 int 1.1.3 { } 1.1.4 printf()库函数 1.1.5 stdio.h头文件 1.2 C语言的…

#LT8713SX适用于Type-C/DP1.4转三路Type-C/DP1.4/HDMI2.0应用方案,分辨率高达4K60HZ,支持SST/MST功能。

1. 描述 LT8713SX是一款高性能Type-C/DP1.4转Type-C/DP1.4/HD-DVI2.0转换器,具有三个可配置的DP1.4/HD-DVI2.0/DP输出接口和音频输出接口。LT8713SX 支持 DisplayPort™ 单流传输 (SST) 模式和多流传输 (MST) 模式。当…

韵达国际邀您参观2024杭州快递物流供应链与技术装备展览会

2024年7月8-10日 | 杭州国际博览中心 同期举办:数字物流技术展 新能源商用车及物流车展 电商物流包装展 冷链物流展 展会介绍 2024长三角快递物流供应链与技术装备展览会(杭州),于2024年7月8-10日在杭州国际博览中心召开&#…

LeetCode每日一题【206. 反转链表】

思路:双指针,一前一后,逐个把指向后面的指针指向前面。 /*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode() : val(0), next(nullptr) {}* ListNode(int x) : val(x), ne…

Unity Mesh简化为Cube mesh

Mesh简化为Cube mesh 🍳食用🥙子物体独立生成CubeMesh🥪合并成一个CubeMesh🌭Demo 🍳食用 下载并导入插件👈即可在代码中调用。 🥙子物体独立生成CubeMesh gameObject.ToCubeMesh_Invidual()…

109 项目整合 spring-quartz 启动自动执行定时任务

前言 项目中使用了 quartz 来支持定时任务的相关基础支撑, 但是 最近添加了一个 资源消耗比较高的定时任务, 发布到测试环境之后, 发现服务突然 起不起来了[资源比较有限] 然后 查看了一下日志, 这个定时任务怎么在执行?, 不是 配置的是 凌晨两点么, 然后 仔细一看 几乎配置…

jscpd检测代码的重复率

官方文档:jscpd jscpd 是一个开源的代码重复检测工具,它用于查找代码中的重复部分并生成相应的报告 1、比较两个目录之间的差异 yarn jscpd --skipLocal sre/test1/** sre/test2 --reporters html生成报告文档在 ./report/html 下面,可以打开…

linux下用docker安装mysql及导入文件

目录 1. 非root用户设置docker权限2. user账号安装mysql2. root账号打开防火墙3. 启动mysql容器3.1 在指定工作目录下建立文件夹3.2 配置文件3.3 开启mysql容器 4. 进入容器4.1 通过容器进入mysql4.1 设置账号4.2 建立数据库4.3 导入文件 5. windows连接数据库参考文件 1. 非ro…

水泥领域智慧工厂物联网解决方案

水泥领域智慧工厂物联网解决方案 在水泥生产行业中,构建智慧工厂物联网解决方案已经成为推动产业升级、实现智能制造的关键路径。该方案深度融合了先进的信息技术与传统的水泥生产工艺,通过全面感知、可靠传输、智能处理等环节,实现了对整个…