Giter VIP home page Giter VIP logo

interface-prometheus-manual's Introduction

Interface prometheus-manual

This is a Juju interface layer that enables a charm which provides manual or raw metric scraper job configuration stanzas for Prometheus 2.

The format for the job configuration data can be found in the Prometheus Configuration Docs. The job configuration will be included as an item under scrape_configs largely unchanged, except for two things:

  • To ensure uniqueness, the provided job name will have a UUID appended to it.
  • Because the CA cert, client cert and key must be written to disk separately from the config, any tls_config sections will have their ca_file, cert_file and key_file field values replaced with the path to the file where the provided ca_cert, client_cert and client_key data is written respectively.

Example Usage

First, you must define the relation endpoint in your charm's metadata.yaml:

provides:
  prometheus:
    interface: prometheus-manual

Next, you must ensure the interface layer is included in your layer.yaml:

includes:
  - interface:prometheus-manual

Then, in your reactive code, add the following, modifying the job data as your charm needs:

from charms.reactive import endpoint_from_flag


@when('endpoint.prometheus.joined',
      'tls.ca.available')
def register_prometheus_jobs():
    prometheus = endpoint_from_flag('endpoint.prometheus.joined')
    tls = endpoint_from_flag('tls.ca.available')
    prometheus.register_job(job_name='kubernetes-apiservers',
                            ca_cert=tls.root_ca_cert,
                            job_data={
                                'kubernetes_sd_configs': [{'role': 'endpoints'}],
                                'scheme': 'https',
                                'tls_config': {'ca_file': '__ca_file__'},  # placeholder for saved filename
                                'bearer_token': get_token('system:prometheus'),
                            })
    prometheus.register_job(job_name='kubernetes-nodes',
                            ca_cert=tls.root_ca_cert,
                            job_data={
                                'kubernetes_sd_configs': [{'role': 'node'}],
                                'scheme': 'https',
                                'tls_config': {'ca_file': '__ca_file__'},  # placeholder for saved filename
                                'bearer_token': get_token('system:prometheus'),
                            })

Reference

Contact Information

Maintainer: Cory Johns <[email protected]>

interface-prometheus-manual's People

Contributors

johnsca avatar hyperbolic2346 avatar simondeziel avatar

Watchers

James Cloos 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.