Skip to content

Prometheus

Prometheus

Query prometheus database for stats and other information. It also allows you to subscribe to alters using alertmanager.

Description

Prometheus integration gives you ability to query your stats and other information and to run other management commands using maira commands.

You can also send your alerts to maira using Prometheus alertmanager webhook.

Installation

For integrating with prometheus, you need to provide your prometheus host addresses and authorization token. Make sure that service_name is set as prometheus and there is one cluster named prometheus-default since this will be used by default if no cluster is specified in the command.

Helm Config

Below is sample configuration for enabling prometheus integration through Helm Chart Values file

prometheus:
  disabled: false
  clusters:
    prometheus-default:
      url: "http://localhost:9090"
  • disabled tag can be set to true to temporarily disable the service without removing the config
  • multiple clusters can be added under tag "clusters"

Direct Config

Below is sample configuration for enabling prometheus integration

modules:
  - name: maira_io.module.http
services:
  - name: maira_io.service.http
    typed_config:
      "@type": types.google.com/maira_io.config.service.http.v1.Config
      clusters:
        - name: prometheus-default
          addresses:
            - "http://localhost:9090"
          request_headers_add:
            "content-type": "application/x-www-form-urlencoded"
          service_name: prometheus

AlertManager integration

Maira also integrates with Prometheus alertmanager to send alerts to maira. Maira can then act on those alerts to run previously defined playbook. Below is the sample alertmanager config that you will have to do, where site_name is to be replaced with the actual site name and CLIENT_ID and CLIENT_SECRET are to be replaced with client id and secret for your team.

route:
  group_by: ['alertname']
  group_wait: 10s
  group_interval: 10s
  repeat_interval: 1h
  receiver: 'maira'
receivers:
- name: 'maira'
  webhook_configs:
  - url: 'https://api.demo.maira.io/events/site/<site_name>'
    http_config:
      oauth2:
        client_id: <CLIENT_ID>
        client_secret: <CLIENT_SECRET>
        token_url: 'https://maira-dev.us.auth0.com/oauth/token'
        endpoint_params: 
          audience: 'https://api.maira-dev.maira.io/event'