参考内容

东方通应用服务器软件TongWeb_V7.0工具使用指南:
在这里插入图片描述

准备工作

1.已安装好tongweb7049m10.
2.找到文档上提及的prometheus-client.war。
3.已安装好prometheus。
4.已安装好grafana。

备注:
本帖提供的方式,仅包含JVM监控信息。

操作说明

创建账号

先通过thanos这个账号登录控制台(初始密码thanos123.com),通过安全域新建一个用户,避免在使用prometheus的时候,多次顶号thanos:

在这里插入图片描述

创建账号的时候,注意是否设置密码过期(如果勾选密码过期开关,默认是90天,记得自己过期后修改下密码):

在这里插入图片描述

创建后同一个地方,配置security的密码:

在这里插入图片描述

配置后退出thanos账号,使用security登录:

在这里插入图片描述
登录后点创建好的用户名,分配角色为系统管理员:
在这里插入图片描述
在这里插入图片描述
退出security,用新账号登录测试看看能不能登录:

在这里插入图片描述

部署相关war包

用thanos登录,首页配置一下服务器可选文件路径:
在这里插入图片描述
window本地解压tongweb的安装包,找到这个war包,用zip工具打开:
在这里插入图片描述
找到twpermissions.properties:

在这里插入图片描述

把开头的tongweb改成新建的用户名,然后保存。
在这里插入图片描述

WEB-INF/web.xml检查一下param-value标签里的值是不是defaultRealm。
在这里插入图片描述

上传修改好的war包到配置好的服务器可选文件的路径,然后通过控制台部署该war包:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
或者也可以使用自动部署功能,将war包丢到tongweb的autodeploy目录下,然后看控制台看看是否触发到自动部署:

在这里插入图片描述

部署成功后,访问:

http://服务器ip:8088/prometheus-client/metrics?username=创建的用户名&password=用户密码

在这里插入图片描述

备注:

如果嫌通过控制台部署比较麻烦,也可以把已改好的war包,丢到tongweb的autodeploy目录下,成功部署后,会在deployment目录生成目录,并可以直接访问。

配置到prometheus

本次示范为配置到prometheus.yml,仅供参考,更多方式可以上网搜:
在这里插入图片描述

以http://192.168.10.12:8088/prometheus-client/metrics?username=yehuorufeng&password=Yeyehuo164.com为例:

# 新增的配置
  - job_name: 'my-tongweb-service'
    metrics_path: '/prometheus-client/metrics'
    params:
      username: ['yehuorufeng']
      password: ['Yeyehuo164.com']
    static_configs:
      - targets: [ '192.168.10.12:8088' ]

配置后重启prometheus,再去访问prometheus的targethealth看看:

在这里插入图片描述

grafana 配置(仅供参考)

进入到grafana,选择这里:
在这里插入图片描述

在这里插入图片描述

进去后输入prometheus的url(这里因为prometheus和grafana均为同一个docker安装,所以用的http://prometheus:9090)
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
下面有个save and test,试试看能不能测通
在这里插入图片描述
在这里插入图片描述
然后回到首页,点这里:

在这里插入图片描述
在这里插入图片描述
上传一下仪表盘的json文件(下面提供一个,仅供参考,是用ai写的,请根据自身需求调整):

在这里插入图片描述

备注:
默认设置的是刷新时间为30s,如果需要调整,可以到页面调整:

在这里插入图片描述

或者在导入前,搜索“refresh”关键字,进行修改:
在这里插入图片描述

下面是脚本内容:

{
  "annotations": {
    "list": []
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": null,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "expr": "tongtech_tongweb_jvm_threading_detail_gauge{name=\"ThreadCount\"}",
          "legendFormat": "活跃线程",
          "refId": "A"
        }
      ],
      "title": "JVM 线程数",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 1
              }
            ]
          },
          "unit": "none"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 6,
        "y": 0
      },
      "id": 2,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "expr": "tongtech_tongweb_hung_thread_gauge",
          "legendFormat": "Hung 线程",
          "refId": "A"
        }
      ],
      "title": "Hung 线程",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 12,
        "y": 0
      },
      "id": 3,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "expr": "tongtech_tongweb_operating_system_usage{name=\"CpuPercent\"}",
          "legendFormat": "CPU 使用率",
          "refId": "A"
        }
      ],
      "title": "CPU 使用率",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 18,
        "y": 0
      },
      "id": 4,
      "options": {
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "expr": "tongtech_tongweb_operating_system_usage{name=\"MemPercent\"}",
          "legendFormat": "内存使用率",
          "refId": "A"
        }
      ],
      "title": "内存使用率",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 4
      },
      "id": 5,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "tongtech_tongweb_jvm_memory_detail_gauge{name=\"HeapMemoryUsage_used\"}",
          "legendFormat": "堆内存已用",
          "refId": "A"
        },
        {
          "expr": "tongtech_tongweb_jvm_memory_detail_gauge{name=\"HeapMemoryUsage_max\"}",
          "legendFormat": "堆内存最大",
          "refId": "B"
        },
        {
          "expr": "tongtech_tongweb_jvm_memory_detail_gauge{name=\"HeapMemoryUsage_committed\"}",
          "legendFormat": "堆内存已分配",
          "refId": "C"
        }
      ],
      "title": "JVM 堆内存",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 4
      },
      "id": 6,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "tongtech_tongweb_jvm_memory_detail_gauge{name=\"NonHeapMemoryUsage_used\"}",
          "legendFormat": "非堆内存已用",
          "refId": "A"
        },
        {
          "expr": "tongtech_tongweb_jvm_memory_detail_gauge{name=\"NonHeapMemoryUsage_committed\"}",
          "legendFormat": "非堆内存已分配",
          "refId": "B"
        }
      ],
      "title": "JVM 非堆内存",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 12
      },
      "id": 7,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "tongtech_tongweb_jvm_threading_detail_gauge{name=\"ThreadCount\"}",
          "legendFormat": "当前线程数",
          "refId": "A"
        },
        {
          "expr": "tongtech_tongweb_jvm_threading_detail_gauge{name=\"PeakThreadCount\"}",
          "legendFormat": "峰值线程数",
          "refId": "B"
        },
        {
          "expr": "tongtech_tongweb_jvm_threading_detail_gauge{name=\"deadlockedThreadCount\"}",
          "legendFormat": "死锁线程数",
          "refId": "C"
        }
      ],
      "title": "JVM 线程",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 12
      },
      "id": 8,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "rate(tongtech_tongweb_jvm_garbage_collector_detail_gauge{name=\"_CollectionTime\"}[1m])",
          "legendFormat": "GC 时间速率",
          "refId": "A"
        },
        {
          "expr": "rate(tongtech_tongweb_jvm_garbage_collector_detail_gauge{name=\"_CollectionCount\"}[1m])",
          "legendFormat": "GC 次数速率",
          "refId": "B"
        }
      ],
      "title": "JVM 垃圾回收",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 20
      },
      "id": 9,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "tongtech_tongweb_jvm_classloading_detail{name=\"LoadedClassCount\"}",
          "legendFormat": "已加载类数",
          "refId": "A"
        },
        {
          "expr": "tongtech_tongweb_jvm_classloading_detail{name=\"TotalLoadedClassCount\"}",
          "legendFormat": "累计加载类数",
          "refId": "B"
        },
        {
          "expr": "tongtech_tongweb_jvm_classloading_detail{name=\"UnloadedClassCount\"}",
          "legendFormat": "已卸载类数",
          "refId": "C"
        }
      ],
      "title": "JVM 类加载",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "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
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 20
      },
      "id": 10,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "expr": "tongtech_tongweb_listener_gauge{connectorName=\"tong-http-listener\",name=\"currentThreadCount\"}",
          "legendFormat": "tong-http 当前线程",
          "refId": "A"
        },
        {
          "expr": "tongtech_tongweb_listener_gauge{connectorName=\"tong-http-listener\",name=\"requestCount\"}",
          "legendFormat": "tong-http 请求数",
          "refId": "B"
        },
        {
          "expr": "tongtech_tongweb_listener_gauge{connectorName=\"system-http-listener\",name=\"currentThreadCount\"}",
          "legendFormat": "system-http 当前线程",
          "refId": "C"
        },
        {
          "expr": "tongtech_tongweb_listener_gauge{connectorName=\"system-http-listener\",name=\"requestCount\"}",
          "legendFormat": "system-http 请求数",
          "refId": "D"
        }
      ],
      "title": "TongWeb 连接器",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "custom": {
            "align": "auto",
            "displayMode": "auto",
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 6,
        "w": 24,
        "x": 0,
        "y": 28
      },
      "id": 11,
      "options": {
        "footer": {
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "expr": "tongtech_tongweb_tongweb_server_detail_info",
          "format": "table",
          "instant": true,
          "legendFormat": "",
          "refId": "A"
        }
      ],
      "title": "TongWeb 服务器信息",
      "type": "table"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [
    "tongweb",
    "jvm",
    "middleware"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "Prometheus",
          "value": "Prometheus"
        },
        "hide": 0,
        "includeAll": false,
        "label": "数据源",
        "multi": false,
        "name": "datasource",
        "options": [],
        "query": "prometheus",
        "queryValue": "",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "TongWeb 监控仪表盘",
  "uid": "tongweb-monitor",
  "version": 1,
  "weekStart": ""
}
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐