Giter Site home page Giter Site logo

verygood-ops / open-metrics-multi-tenancy-kit Goto Github PK

View Code? Open in Web Editor NEW
4.0 12.0 2.0 168 KB

Metrics collection and rules management for Cortex on Kubernetes

License: Apache License 2.0

Makefile 0.26% Rust 96.89% Python 0.63% Dockerfile 2.22%
prometheus-metrics prometheus-alert-rules multi-tenancy open-metrics team-platform-services

open-metrics-multi-tenancy-kit's Introduction

open-metrics-multi-tenancy-kit

example workflow

open-metrics-multi-tenancy-kit implements multi-tenancy for metrics collection and rules management in Cortex environments, configured via OpenMetricsRule Kubernetes resource.

An example OpenMetricsRule is below.

apiVersion: "open-metrics.vgs.io/v1"
kind: "OpenMetricsRule"
metadata:
  name: open-metrics-test
  namespace: open-metrics-test
spec:
  tenants:
    - "backoffice"
    - "frontend"
  description: "A hello world rule for recording and alerting."
  groups:

    - name: open_metrics_rule_record_v0
      interval: 1m
      rules:
        - expr: histogram_quantile(0.99, rate(http_request_processing_duration_ms_bucket[5m]))
          record: p99:http_request_duration_ms:5m
        - expr: histogram_quantile(0.99, rate(http_request_processing_duration_ms_bucket[2m]))
          record: p99:http_request_duration_ms:2m

    - name: open_metrics_rule_alert_v0
      rules:
        - expr: p99:http_request_duration_ms:5m > 400
          for: 5m
          alert: HttpRequestProcessingP99TooLarge
          labels:
            severity: critical

Metrics collection multi-tenancy

A proxy component introspects Prometheus GRPC metrics remote_write stream, injects tenants in accordance to Cortex Authentication and Authorization, and forwards requests to specified upstream. Tenants can be specified either via command line, or specified via spec.tenants property of OpenMetricsRule Kubernetes resource.

See proxy/README.md for futher details on open-metrics-multi-tenancy-proxy functioning.

Rule And Alert Management

Metrics rules, both tecording and alerting are set up via OpenMetricsRule Kubernetes resources. An informer component loads rules into Ruler.

See informer/README.md for futher details on open-metrics-multi-tenancy-proxy functioning.

Open metrics exposition

TBD.

Rule expression validation

TBD.

How to build

Local:

  1. Install Rust
  2. Install protobuf-compiler
  3. cargo build

In docker,

docker-compose build

How to test

On localhost,

RUST_LOG=debug RUST_BACKTRACE=full cargo test -- --nocapture

Docker:

docker-compose run test

How to run

On localhost,

Run proxy

RUST_LOG=debug RUST_BACKTRACE=full cargo run \
    --bin open-metrics-multi-tenancy-proxy

Run informer

RUST_LOG=debug RUST_BACKTRACE=full cargo run \
    --bin open-metrics-multi-tenancy-informer

In Docker,

docker-compose up

How to monitor

Use Prometheus!

A proxy component exposes following Prometheus metrics:

  • open_metrics_proxy_requests -- number of requests to distributor, per tenant
  • open_metrics_proxy_series -- number of forwarded series, per tenant
  • open_metrics_proxy_failures -- number of forwarding errors, per process
  • open_metrics_proxy_labels -- number of requests to distributor, per process
  • open_metrics_proxy_metadata -- number of metrics metadata seen (usually for each kind of metrics forwarded once)
  • open_metrics_proxy_processing_ms -- histogram of durations

An informer component exposes following prometheus metrics:

  • open_metrics_informer_tracker_rules -- number of rules seen by tracker, per tenant
  • open_metrics_informer_tracker_tenants -- increases each time new tenant seen in tracker rules, per tenant
  • open_metrics_informer_updater_rules -- number of rules seen by updater, per tenant
  • open_metrics_informer_updater_tenants -- increases each time new tenant seen in updater rules, per tenant

Known limitations

  • no validation for duplicated recording rules or alerts
  • no support for multiple Kubernetes namespaces
  • no real health check for proxy or informer (can be remediated by using Prometheus metrics)

open-metrics-multi-tenancy-kit's People

Contributors

mjallday avatar rayvgs avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.