【问题标题】:Prometheus won't connect to Synapse metricsPrometheus 不会连接到 Synapse 指标
【发布时间】:2020-08-20 23:15:00
【问题描述】:

我尝试按照本指南为 prometheus 配置突触指标:https://github.com/matrix-org/synapse/blob/master/docs/metrics-howto.md

但我遇到了困难。我是这样设置的:

$ sudo ufw 允许 9090

$ sudo nano /etc/matrix-synapse/homeserver.yaml

# in listeners: list
  - type: metrics
    port: 9000
    bind_addresses:
      - '0.0.0.0'

## Metrics ###

# Enable collection and rendering of performance metrics
#
enable_metrics: true

重启 Synapse,安装 Docker。

创建 '/etc/prometheus/prometheus.yml' 像这样编辑它:

$ sudo nano /etc/prometheus/prometheus.yml

# my global config
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).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: "synapse"
    metrics_path: "/_synapse/metrics"
    scheme: "https"
    static_configs:
      - targets: ["localhost:9000"]

尝试启动 Prometheus:

$ docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus prom/prometheus

level=info ts=2020-05-06T03:42:50.799Z caller=main.go:298 msg="no time or size retention was set so using the default time retention" duration=15d
level=info ts=2020-05-06T03:42:50.799Z caller=main.go:333 msg="Starting Prometheus" version="(version=2.17.2, branch=HEAD, revision=18254838fbe25dcc732c950ae05f78ed4db1292c)"
level=info ts=2020-05-06T03:42:50.799Z caller=main.go:334 build_context="(go=go1.13.10, user=root@9cb154c268a2, date=20200420-08:27:08)"
level=info ts=2020-05-06T03:42:50.800Z caller=main.go:335 host_details="(Linux 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1+deb10u1 (2020-04-27) x86_64 0cf4549b1dcd (none))"
level=info ts=2020-05-06T03:42:50.800Z caller=main.go:336 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2020-05-06T03:42:50.800Z caller=main.go:337 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2020-05-06T03:42:50.802Z caller=main.go:667 msg="Starting TSDB ..."
level=info ts=2020-05-06T03:42:50.802Z caller=web.go:515 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2020-05-06T03:42:50.806Z caller=head.go:575 component=tsdb msg="replaying WAL, this may take awhile"
level=info ts=2020-05-06T03:42:50.806Z caller=head.go:624 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2020-05-06T03:42:50.807Z caller=head.go:627 component=tsdb msg="WAL replay completed" duration=403.999µs
level=info ts=2020-05-06T03:42:50.808Z caller=main.go:683 fs_type=9123683e
level=info ts=2020-05-06T03:42:50.808Z caller=main.go:684 msg="TSDB started"
level=info ts=2020-05-06T03:42:50.808Z caller=main.go:788 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2020-05-06T03:42:50.809Z caller=main.go:816 msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2020-05-06T03:42:50.810Z caller=main.go:635 msg="Server is ready to receive web requests."

但它只是将控制台从我身边拿走。 :P 我至少可以在运行时拆下它。

我可以在 192.168.1.171:9090 看到 Prometheus,但它没有记录/显示突触指标。 :/

从这里下载 synapse-v2.rules:https://github.com/matrix-org/synapse/tree/master/contrib/prometheus

编辑:感谢我编辑了 https 部分,并将其指向新的规则文件,这是我的 prometheus.yml:

# my global config
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).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  - "/etc/prometheus/synapse-v2.rules"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: "synapse"
    metrics_path: "/_synapse/metrics"
    static_configs:
      - targets: ["localhost:9000"]

然后我重新启动了 Prometheus docker,但它仍然没有在 web 下拉列表中显示突触指标。

There are prometheus statistics but no synapse ones.

【问题讨论】:

    标签: matrix prometheus synapse


    【解决方案1】:

    scheme: "https"

    Synapse 的指标监听器不使用 tls。删除这个。

    【讨论】:

    • 感谢我更改了 Prometheus 配置,如您在上面看到的,但它仍然无法识别 Synapse 统计信息:S
    【解决方案2】:
    static_configs:
      - targets: ["localhost:9000"]
    

    $ docker run -p 9090:9090 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus prom/prometheus

    localhost 这里是 Docker 容器的localhost。只有 Docker 容器中的东西可以在那里访问。

    【讨论】:

    • 我也发布了 9000 端口,如下所示:“$ docker run -p 9090:9090 -p 9000:9000 -v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus. yml --name prometheus prom/prometheus &" 但是 docker 向我吐出这个错误:"$ docker:来自守护进程的错误响应:驱动程序在端点 prometheus 上编程外部连接失败(e52df6b1358a0aaf710e046163efc774f52d08e0e8486840a1a294b3d3b4badf):启动用户级代理时出错:监听 tcp 0. :9000: bind: address already in use. ERRO[0019] error waiting for container: context cancelled"
    【解决方案3】:

    尝试下载已编译的包并运行它,效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-23
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      相关资源
      最近更新 更多