Skip to content

Prometheus

Lyes S edited this page May 21, 2022 · 2 revisions

Table Of Contents

Configuration

Please refer to the official documentation for more information : Configuration | Prometheus

# Global Config
global:

  # Set the scrape interval to every 15 seconds.
  # Default is every 1 minute.
  scrape_interval: 15s

  # Evaluate rules every 15 seconds.
  # The default is every 1 minute.
  evaluation_interval: 15s

  # Global Timeout
  # Default is every 10 seconds.
  scrape_timeout: 5s

# Load rules once
# Periodically evaluate according to the global 'evaluation_interval'.
rule_files:
  - rules.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - alertmanager:9093


scrape_configs:

  - job_name: prometheus
    metrics_path: /metrics
    scrape_interval: 5s
    static_configs:
      - targets:
          - prometheus:9090

  - job_name: alertmanager
    metrics_path: /metrics
    scrape_interval: 5s
    static_configs:
      - targets:
          - alertmanager:9093

  - job_name: cadvisor
    metrics_path: /metrics
    scrape_interval: 5s
    static_configs:
      - targets:
          - cadvisor:8080

  - job_name: node-exporter
    metrics_path: /metrics
    scrape_interval: 5s
    static_configs:
      - targets:
          - node-exporter:9100

  - job_name: postgres-exporter
    metrics_path: /metrics
    scrape_interval: 5s
    static_configs:
      - targets:
          - postgres-exporter:9187

  - job_name: consul
    metrics_path: /v1/agent/metrics
    scrape_interval: 5s
    params:
      format: ['prometheus']
    static_configs:
      - targets:
          - consul:8500

  - job_name: network-device-inventory
    metrics_path: /inventory/api/actuator/prometheus
    scrape_interval: 5s
    consul_sd_configs:
      - server: consul:8500
        scheme: http
        services:
          - network-device-inventory
    relabel_configs:
      - source_labels: [ '__meta_consul_service',  '__meta_consul_service_port']
        separator: ':'
        target_label: __address__

Alerting Rules

Please refer to the official documentation for more information : Alerting Rules | Prometheus

groups:
  - name: alerts
    rules:
      # Alert for any instance that is unreachable for 1 minutes.
      - alert: InstanceDown
        # Condition for alerting
        expr: up == 0
        for: 1m
        # Labels - additional labels to be attached to the alert
        labels:
          severity: critical
        # Annotation - additional informational labels to store more information
        annotations:
          summary: "Instance {{ $labels.instance }} down"
          description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 1 minutes."
Clone this wiki locally