关于promethus+grafana的监控exporter访问/为errorpage404(notfound)重写exporter

因为grafana需要exported为ip:port形式,但是如下图,访问/报错:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Aug 12 16:21:50 CST 2022
There was an unexpected error (type=Not Found, status=404).
No message available

在这里插入图片描述

访问/metrics可以正常访问得到数据
在这里插入图片描述
可是grafana不认这个帐导致add sources时候not found,无法成功添加数据源
在这里插入图片描述
于是只能让ip:port/界面可以正常的使用。

这里以exported_rockermq为例子
打开exported_rockermq,妥妥的java_spring项目,那就简单了,直接一路打开看controller、sevice层,发现只有一个/metrics界面,自己添加一个简单的/节面就行了

改变两个文件一个是application文件,namesrvAddr是监控的rocketmq地址自行更改,加了一个

webTelemetry:/

在这里插入图片描述
完整配置如下所示

server:
  port: 5557
spring:
  application:
    name: rocketmq-exporter
  http:
    encoding:
      charset: UTF-8
      enabled: true
      force: true
logging:
  config: classpath:logback.xml

rocketmq:
  config:
    webTelemetry: /
    webTelemetryPath: /metrics
    rocketmqVersion: 4_8_0
    namesrvAddr: 10.37.0.216:9876
    enableCollect: true
    enableACL: false # if >=4.4.0
    accessKey:  # if >=4.4.0
    secretKey:  # if >=4.4.0
    outOfTimeSeconds: 60 # Cache clear time with no update

threadpool:
  collect-client-metric-executor:
    core-pool-size: 10
    maximum-pool-size: 10
    keep-alive-time: 3000
    queueSize: 5000
task:
  count: 5 # num of scheduled-tasks
  collectTopicOffset:
    cron: 15 0/1 * * * ?
  collectConsumerOffset:
    cron: 15 0/1 * * * ?
  collectBrokerStatsTopic:
    cron: 15 0/1 * * * ?
  collectBrokerStats:
    cron: 15 0/1 * * * ?
  collectBrokerRuntimeStats:
    cron: 15 0/1 * * * ?

再去controller层修改他的页面跳转代码在这里插入图片描述
只是多了一个跳转/界面的返回html的代码,完整代码如下:

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.rocketmq.exporter.controller;


import org.apache.rocketmq.exporter.service.RMQMetricsService;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;

@RestController
@EnableAutoConfiguration
public class RMQMetricsController {
    @Resource
    RMQMetricsService metricsService;

    @RequestMapping(value = "${rocketmq.config.webTelemetryPath}")
    @ResponseBody
    private void metrics(HttpServletResponse response) throws IOException {
        StringWriter writer = new StringWriter();
        metricsService.metrics(writer);
        response.setHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8");
        response.getOutputStream().print(writer.toString());
    }
	
	@RequestMapping(value = "${rocketmq.config.webTelemetry}")
    @ResponseBody
    private void mtcs(HttpServletResponse response) throws IOException {
        /*ringWriter writer = new StringWriter();
        tricsService.metrics(writer);
        response.setHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8");
		*/
		PrintWriter out = response.getWriter();
        //sponse.getOutputStream().print(writer.toString());
		out.write("<h1>MongoDB exporter</h1>");
		out.write("<p><a href='/metrics'>Metrics</a></p>");
    }
}

本地运行一下看看,没啥问题了
在这里插入图片描述
在这里插入图片描述

再把jar包mvn clean package重新打包编译,放到服务器运行就完事了
在这里插入图片描述

这个加到grafana就不会报错not found了,就可以愉快的监控这些中间件了
这是监控redis的json文件官网地址
https://grafana.com/grafana/dashboards/10477-rocketmq-dashboard/?tab=revisions
json文件内容如下:

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "5.4.3"
    },
    {
      "type": "panel",
      "id": "graph",
      "name": "Graph",
      "version": "5.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "5.0.0"
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": "-- Grafana --",
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "gnetId": 10477,
  "graphTooltip": 0,
  "id": 1,
  "links": [],
  "panels": [
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 7,
        "x": 0,
        "y": 0
      },
      "id": 12,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_broker_tps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_broker_qps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "broker tps & broker qps",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 9,
        "x": 7,
        "y": 0
      },
      "id": 8,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_consumer_offset",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_consumer_offset",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 8,
        "x": 16,
        "y": 0
      },
      "id": 16,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_consumer_message_size",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_consumer_message_size",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "decimals": null,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 7,
        "x": 0,
        "y": 6
      },
      "id": 6,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_producer_offset",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_producer_offset",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "description": "消费tps",
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 7,
        "y": 6
      },
      "id": 4,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_consumer_tps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_consumer_tps",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 6
      },
      "id": 14,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_producer_message_size",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_producer_message_size",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "datasource": "${DS_PROMETHEUS}",
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 7,
        "x": 0,
        "y": 13
      },
      "id": 2,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_producer_tps",
          "format": "time_series",
          "hide": false,
          "instant": false,
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_producer_tps",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 9,
        "x": 7,
        "y": 13
      },
      "id": 10,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_group_get_latency_by_storetime",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_group_get_latency_by_storetime",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 6,
        "w": 8,
        "x": 16,
        "y": 13
      },
      "id": 18,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": true,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "sum(rocketmq_producer_offset) by (topic) - on(topic)  group_right  sum(rocketmq_consumer_offset) by (group,topic)",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "rocketmq_message_accumulation",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 0,
        "y": 19
      },
      "id": 20,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_brokeruntime_pmdt_0ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_0to10ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_10to50ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_50to100ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "D"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_100to200ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "E"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_200to500ms",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "F"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_500to1s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "G"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_1to2s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "H"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_2to3s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "I"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_3to4s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "J"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_4to5s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "K"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_5to10s",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "L"
        },
        {
          "expr": "rocketmq_brokeruntime_pmdt_10stomore",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "M"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "PutMessageDistributeTime",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "decimals": null,
          "format": "short",
          "label": "",
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 8,
        "y": 19
      },
      "id": 28,
      "legend": {
        "alignAsTable": false,
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "rightSide": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_brokeruntime_pull_threadpoolqueue_headwait_timemills",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_brokeruntime_query_threadpoolqueue_headwait_timemills",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_brokeruntime_send_threadpoolqueue_headwait_timemills",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "threadpoolqueue_headwait_timemills",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 7,
        "w": 8,
        "x": 16,
        "y": 19
      },
      "id": 30,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_client_consume_fail_msg_count",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_client_consume_fail_msg_tps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_client_consume_ok_msg_tps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        },
        {
          "expr": "rocketmq_client_consume_rt",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "D"
        },
        {
          "expr": "rocketmq_client_consumer_pull_rt",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "E"
        },
        {
          "expr": "rocketmq_client_consumer_pull_tps",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "F"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "consume client info",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 0,
        "y": 26
      },
      "id": 26,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_brokeruntime_getfound_tps10",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_brokeruntime_gettotal_tps10",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_brokeruntime_gettransfered_tps10",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        },
        {
          "expr": "rocketmq_brokeruntime_getmiss_tps10",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "D"
        },
        {
          "expr": "rocketmq_brokeruntime_put_tps10",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "E"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "runtime tps",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 8,
        "y": 26
      },
      "id": 24,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_brokeruntime_commitlog_disk_ratio",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_brokeruntime_consumequeue_disk_ratio",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_brokeruntime_commitlogdir_capacity_free",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        },
        {
          "expr": "rocketmq_brokeruntime_commitlogdir_capacity_total",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "D"
        },
        {
          "expr": "rocketmq_brokeruntime_commitlog_maxoffset",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "E"
        },
        {
          "expr": "rocketmq_brokeruntime_commitlog_minoffset",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "F"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "disk space",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    },
    {
      "aliasColors": {},
      "bars": false,
      "dashLength": 10,
      "dashes": false,
      "fill": 1,
      "gridPos": {
        "h": 8,
        "w": 8,
        "x": 16,
        "y": 26
      },
      "id": 22,
      "legend": {
        "avg": false,
        "current": false,
        "max": false,
        "min": false,
        "show": false,
        "total": false,
        "values": false
      },
      "lines": true,
      "linewidth": 1,
      "links": [],
      "nullPointMode": "null",
      "percentage": false,
      "pointradius": 5,
      "points": false,
      "renderer": "flot",
      "seriesOverrides": [],
      "spaceLength": 10,
      "stack": false,
      "steppedLine": false,
      "targets": [
        {
          "expr": "rocketmq_brokeruntime_msg_put_total_today_now",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "A"
        },
        {
          "expr": "rocketmq_brokeruntime_msg_gettotal_today_now",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "B"
        },
        {
          "expr": "rocketmq_brokeruntime_dispatch_behind_bytes",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "C"
        },
        {
          "expr": "rocketmq_brokeruntime_put_message_size_total",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "D"
        },
        {
          "expr": "rocketmq_brokeruntime_put_message_average_size",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "E"
        },
        {
          "expr": "rocketmq_brokeruntime_msg_gettotal_yesterdaymorning",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "F"
        },
        {
          "expr": "rocketmq_brokeruntime_msg_puttotal_yesterdaymorning",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "G"
        },
        {
          "expr": "rocketmq_brokeruntime_msg_gettotal_todaymorning",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "H"
        },
        {
          "expr": "rocketmq_brokeruntime_msg_puttotal_todaymorning",
          "format": "time_series",
          "intervalFactor": 1,
          "refId": "I"
        }
      ],
      "thresholds": [],
      "timeFrom": null,
      "timeRegions": [],
      "timeShift": null,
      "title": "broker runtime info",
      "tooltip": {
        "shared": true,
        "sort": 0,
        "value_type": "individual"
      },
      "type": "graph",
      "xaxis": {
        "buckets": null,
        "mode": "time",
        "name": null,
        "show": true,
        "values": []
      },
      "yaxes": [
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        },
        {
          "format": "short",
          "label": null,
          "logBase": 1,
          "max": null,
          "min": null,
          "show": true
        }
      ],
      "yaxis": {
        "align": false,
        "alignLevel": null
      }
    }
  ],
  "refresh": false,
  "schemaVersion": 16,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "timezone": "",
  "title": "Rocketmq_dashboard",
  "uid": "zkVx1w_iz",
  "version": 24
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
答:以下是一个示例的docker-compose.yml文件,用于启动Prometheus和Grafana监控一个或多个应用程序: ``` version: '3' services: prometheus: image: prom/prometheus container_name: prometheus ports: - "9090:9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml command: - '--config.file=/etc/prometheus/prometheus.yml' restart: always grafana: image: grafana/grafana container_name: grafana depends_on: - prometheus ports: - "3000:3000" environment: GF_SERVER_ROOT_URL: http://localhost:3000 GF_SECURITY_ADMIN_USER: admin GF_SECURITY_ADMIN_PASSWORD: admin volumes: - ./grafana-data:/var/lib/grafana restart: always ``` 在该docker-compose.yml文件中,我们创建了两个服务:prometheus和grafanaPrometheus服务使用Prometheus Docker映像,并将端口映射到9090。它还将/prometheus.yml文件作为挂载卷传递给容器。在启动容器时,我们使用命令行参数来指定/config.file=/etc/prometheus/prometheus.yml。 Grafana服务程序使用Grafana Docker映像,并依赖于prometheus服务。Grafana服务映射端口3000,并将以下环境变量传递给容器:GF_SERVER_ROOT_URL:使用localhost:3000 (在该容器中内部)作为grafana的根URL,GF_SECURITY_ADMIN_USER和GF_SECURITY_ADMIN_PASSWORD管理Grafana管理员的凭据。此服务还挂载了grafana-data目录,以便可以在重启容器时保留所有Grafana的设置。 最后,我们定义了restart: always参数以确保容器在退出时自动重新启动。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值