Git Product home page Git Product logo

ibm-grafana-ocpthanos-proxy's Introduction

ibm-grafana-ocpthanos-proxy

A simple proxy between Grafana and Openshift Container Platform (OCP) thanos-querier service with multi-tenancy enabled

Since OCP 4.3 Application monitoring is enabled as a technology preview feature. And there is a thanos-querier service as a global query view to enable user to query both cluster metrics and application metrics.

However OCP does not provide Grafana atop of it. This project makes it much easier for user building its own Grafana using the service as its data source. In the meanwhile, it enables namespaces based multi-tenancy support.

Command line options

  • --listen-address The address ibm-grafana-ocpthanos-proxy should listen on. Default value: 127.0.0.1:9096
  • --url-prefix url prefix of the proxy. Default value is "/"
  • --thanos-address The address of thanos-querier service. Default value: https://thanos-querier.openshift-monitoring.svc:9091
  • --ns-parser-conf NSParser configurate file location. Default value: "/etc/conf/ns-config.yaml"
  • --thanos-token-file The token file passed to OCP thanos-querier service for authentication. Default value: "/var/run/secrets/kubernetes.io/serviceaccount/token"
  • --ns-label-name The name of metrics' namespace label. Defalut value: namespace

Getting Started

The example below can not be used in production environment. It production environment it should be used as sidecar of Grafana Pod and listen to loopback interface only.

  1. Enable OCP Application monitoring according to OCP official document. If you just want to play with cluster metrics this step can be ignored.
  2. Set up this proxy as a standalone OCP service. It can be done by oc create -f example/openshift.yaml. The default configuration assuming you have IBM Common Services installed and it uses its IAM service as namespace provider. If you do not have IBM Common Services installed, edit example/openshift.yaml to update its thanos-proxy-ns-config configmap to use another namespace provider.
  3. Install Grafana into your cluster. You can install it via IBM Common Service Grafana or the community Grafana operator from OCP OperatorHub.
  4. Configure thanos-proxy as datasource of Grafana
    • click Add data source button on grafana's datasources configuration page and select Promethues datasource type.
    • Name the datasource name as thanos
    • use http://thanos-proxy:9096 as HTTP URL
    • add cfc-access-token-cookie into Whitelisted Cookies if you are using IBM Common Service Grafana.
  5. Now you are ready to create Grafana dashboard using thanos as its datasource.

Limitations

  1. The proxy does not provide TLS encryption and any authentication/authorization. It is expected to be used as sidecar of Grafana pod and listen to loopback interface only.
  2. The proxy use namespace label as matcher for multi-tenancy. So the query in Grafana should only use following format matcher for namespace label.
    • No namespace matcher at all. The query will be updated to metric_name{namespace=~"namespace1|namespace2"}
    • Use Equal operator only. {namespace="namespace1"} for example. If namespace1 is allowed by NSParser, query will be passed onto thanos service without change. Otherwise empty data will be returned.
    • Use simple =~ operator. {namespace=~"namespace1|namespace2"} for example. Query will be passed onto thanos service only if both namespace1 and namespace2 are allowed by NSParser. Otherwise empty data will be returned.

ibm-grafana-ocpthanos-proxy's People

Contributors

ashank07 avatar dongyingbo avatar nobody4t avatar poojasanga avatar prtamilanban avatar smithatv1 avatar stevemar avatar testgod481 avatar tirumalavasa avatar xcliu-ca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ibm-grafana-ocpthanos-proxy's Issues

Other matchers then namespace

Is there a possibility for matching other metrics that don't have the namespace label inside. We want to give our teams insights in the node metrics of the nodes they are using, but not to metrics of the nodes that are used by other teams.

For example.

We have several nodes for a team. We want to give the team insights in the node_cpu_info, instance:node_load1_per_cpu:ratio metric and several other metrics that are available for the nodes.

Valid namespace matchers not recognized

Namespace matchers which are recognized by the proxy are:

  • none
  • namespace="ns1"
  • namespace~="ns1|ns2|ns3"

However, when you create a dashboard in Grafana with a variable (drop down box at the top of the dashboard) for namespace, then Grafana will generate the following in any query that you define with namespace~="$namespace":

  • In case the "All" option is used, it is customary to give that the value ".", so it will indeed select metrics for any namespace. Now when you choose "All", Grafana will generate: `namespace~="."
  • In case multi-select option is used, then Grafana will generate: namespace~="(ns1|ns2|ns3)"

Both situations should be supported by the proxy. .* can be replaced by the generated namespace matcher (see https://github.com/IBM/ibm-grafana-ocpthanos-proxy/blob/master/pkg/proxy/inject.go#L119) and (ns1|ns2|ns3) can be treated exactly like ns1|ns2|ns3.

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.