Prometheus configuration: Difference between revisions

From wikinotes
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is just an overview of prometheus configuration.<br>
Details on syntax and exporter configs can be found in:
* [[prometheus exporters]]
* [[prometheus rules]]
= Documentation =
<blockquote>
{| class="wikitable"
|-
| configuration docs || https://prometheus.io/docs/prometheus/latest/configuration/configuration/
|-
| alerting docs || https://prometheus.io/docs/alerting/latest/configuration/
|-
|}
</blockquote><!-- Documentation -->
= Prometheus =
= Prometheus =
<blockquote>
<blockquote>
== Consuming Exporters ==
== Exporters ==
<blockquote>
<blockquote>


Configure '''jobs''' to poll prometheus metric endpoints within <code>scrape_configs</code>.<br>
Configure '''jobs''' to poll prometheus metric '''exporter''' endpoints within <code>scrape_configs</code>.<br>
For example, the following config polls metrics from <code>http://localhost:9115/metrics</code> every <code>5s</code>.
For example, the following config polls metrics from <code>http://localhost:9115/metrics</code> every <code>5s</code>.


Line 14: Line 30:


scrape_configs:
scrape_configs:
- job_name: blackbox # To get metrics about the exporter itself
  - job_name:     my-server
  metrics_path: /metrics
    metrics_path: /metrics   # (default) route to query metrics from
  static_configs:
    scheme:        http      # (default) scheme to use for query
    - targets:
    static_configs:
      - localhost:9115
      - targets:
        - localhost:9115     # query this ip-addr/port
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Exporters -->
</blockquote><!-- Exporters -->
== Rules ==
<blockquote>
You can configure '''Rules''' to either persist or '''Alerts'''.
<syntaxhighlight lang="yaml">
global:
  evaluation_interval: 15s  # rules evaluated every 15s
alerting:
  alertmanagers:
    - static_configs:
      - targets:
        - alertmanager:9003
rule_files:
  - first_rules.yml
</syntaxhighlight>
</blockquote><!-- Alerts/Rules -->
</blockquote><!-- Prometheus -->
</blockquote><!-- Prometheus -->

Latest revision as of 03:32, 18 February 2022

This is just an overview of prometheus configuration.
Details on syntax and exporter configs can be found in:

Documentation

configuration docs https://prometheus.io/docs/prometheus/latest/configuration/configuration/
alerting docs https://prometheus.io/docs/alerting/latest/configuration/

Prometheus

Exporters

Configure jobs to poll prometheus metric exporter endpoints within scrape_configs.
For example, the following config polls metrics from http://localhost:9115/metrics every 5s.

# /usr/local/etc/prometheus.yml

global:
  scrape_interval: 5s

scrape_configs:
  - job_name:      my-server
    metrics_path:  /metrics   # (default) route to query metrics from
    scheme:        http       # (default) scheme to use for query
    static_configs:
      - targets:
        - localhost:9115      # query this ip-addr/port

Rules

You can configure Rules to either persist or Alerts.

global:
  evaluation_interval: 15s  # rules evaluated every 15s

alerting:
  alertmanagers:
    - static_configs:
      - targets:
        - alertmanager:9003

rule_files:
  - first_rules.yml