如何在prometheus配置文件中指定完整的URL?

时间:2019-06-17 12:45:54

标签: prometheus

我要监视已使用apache-tomact 8部署的应用程序,例如url为hostip:port / login.jsp,但在prometheus配置文件中,我们只能提及hostip:port,我可以在哪里指定额外的login.jsp路径,以便它监视特定的应用程序。

我已经尝试更改mertic_path,但是遇到了一些无效的有效令牌错误。

配置文件:

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

rule_files:
  - 'promrules.yml'


scrape_configs:
  - job_name: 'prometheus'

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

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

  - job_name: 'bank'
    #metrics_path: /login.jsp
    static_configs:
    - targets: ['<hostip>:<port>']

1 个答案:

答案 0 :(得分:0)

使用metrics_path的最小示例配置如下:

- job_name: my-service
  metrics_path: "/custom-metrics-endpoint"
  static_configs:
    - targets:
      - localhost:9090

如果遇到Yaml解析错误,请在路径周围使用引号。