2023-03-03 服务发现

2023-03-02  本文已影响0人  felix_feng

在prometheus.yml中配置的静态功能static_configs 来手工添加主机IP地址与端口。
首先在应用JVM中配置,例如在namenode中配置

-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=65  -XX:+CMSParallelRemarkEnabled  -Xmn8G -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m -XX:+DisableExplicitGC  -XX:+PrintGCDateStamps  -XX:+PrintGCDetails -XX:+PrintReferenceGC   -XX:+PrintGCTimeStamps  -XX:PrintFLSStatistics=1    -XX:+PrintGCCause  -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=20 -XX:GCLogFileSize=20M  -Xloggc:/var/log/hadoop-hdfs/hdfs-namenode-gc.log  -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=/opt/prometheus/conf/cdh/hadoop/hadoop.jmxremote.access -Dcom.sun.management.jmxremote.password.file=/opt/prometheus/conf/cdh/hadoop/hdfs.jmxremote.password -Dcom.sun.management.jmxremote.port=11000 -javaagent:/opt/prometheus/exporter/jmx/jmx_prometheus_javaagent-0.12.0.jar=21000:/opt/prometheus/conf/cdh/hadoop/namenode.yaml

在prometheus.yml配置相应的json路径

 - job_name: 'Hadoop'
    file_sd_configs:
    - files:
      - conf/targets/hadoop/hdfs-namenodes.json
    relabel_configs:
    - source_labels: ["__address__"]
      regex: "(.*?.yto.clound):.*"
      action: replace
      replacement: "$1"
      target_label: "hostname"
    - source_labels: ["__address__"]
      regex: "(.*).yto.clound.*"
      action: replace
      replacement: "$1"
      target_label: "shorthostname"

在hdfs-namenodes.json中定义被监控组件的暴露的端口。
例如

[
    {
        "targets": [
            "srvbd17.yto.clound:21000",
            "srvbd33.yto.clound:21000",
            "srvbd17.yto.clound:9070",
            "srvbd33.yto.clound:9070",
            "srvbd33.yto.clound:9709"
        ],
        "labels": {
            "environment": "Production",
            "scope": "CDH",
            "service": "HDFS",
            "role": "NameNode"
        }
    }
]
上一篇 下一篇

猜你喜欢

热点阅读