Coder Social home page Coder Social logo

smile-sa / rating-operator-api Goto Github PK

View Code? Open in Web Editor NEW
14.0 7.0 1.0 2.52 MB

Kubernetes Operator to transform metrics into KPIs. Support for custom transformations rules. - exposes the rating Operator API

License: Other

Makefile 0.09% Shell 1.06% Dockerfile 0.16% Python 43.70% CSS 50.69% HTML 4.30%
rating-operator rating metrics kpi kpis operator kubernetes kubernetes-operator bi-ops

rating-operator-api's Introduction

rating-operator-api

Used as the communication interface between the rating components, the rating-operator-api is also used to expose metrics to users.

There's two ways to access these metrics:

  • By watching the results on our Grafana dashboards.
  • By querying this API through the exposed endpoints.

In this document we'll explain how to use these endpoints, with examples and expected parameters.

The endpoints are ordered by their resource (namespace, pods, etc..), and the grammar is similar for each category.

Endpoint Description Parameters
GET /instances/list Get the list of the rating rules instances from the local configuration directory. No parameters expected.
GET /instances/get Get the rating rule instance object for a given instance name Expect a payload with : name
POST /instances/add Add and deploy the rating rule instance. Expect a payload with : metric_name template_name and variables values
POST /instances/edit edit the rating rule instance. Expect a payload with : metric_name template_name and variables values
POST /instances/delete Delete a rating rule instance. Expect a payload with : metric_name
GET /templates/list Get the list of all the RatingRules templates names from the local configuration directory. No parameters expected.
GET /templates/get Get the RatingRule template object for a given template. Expect a payload with : query_name
POST /templates/add Add a new RatingRule template. Expect a payload with : query_name query_group and query_template
POST /templates/edit Edit a template configuration. Expect a payload with : query_name query_group and query_template
POST /templates/delete Delete a template configuration. Expect a payload with : query_name
GET /metrics Get the list of metrics. No parameters expected.
GET /metrics/<metric>/rating Get the rating for a given metric. Parameters expected : start end
GET /metrics/<metric>/total_rating Get the aggragated rating for a given metric. Parameters expected : start end
GET /metrics/<metric>/<aggregator> Get the rating for a given metric, according to the aggregator. Available aggregator are: daily weekly monthly
GET /metrics/<metric>/todate Get the rating, from the start of the month to now. No parameters expected.
GET /metrics/<metric>/max Get the max rating for a given metric. Parameters expected : start end
GET /namespaces Get a list of namespaces visibile No parameters expected.
GET /namespaces/rating Get the rating on a time period, grouped by namespaces. Parameters expected : start end
GET /namespaces/total_rating Get the sum of the rating on a time period, grouped by namespaces. Parameters expected : start end
GET /namespaces/metrics/rating Get the rating on a time period, grouped by namespaces and metrics. Parameters expected : start end
GET /namespaces/<namespace>/<aggregator> Get the rating for a namespace, according to the aggregator. Available aggregator are: daily weekly monthly
GET /namespaces/<namespace>/rating Get the rating on a time period, for a given namespace. Parameters expected : start end
GET /namespaces/<namespace>/total_rating Get the sum of the rating on a time period, for a given namespace. Parameters expected : start end
GET /namespaces/<namespace>/metrics/<metric>/rating Get the rating on a time period, for givens namespace and metric. Parameters expected : start end
GET /pods Get the list of pods. Parameters expected : start end
GET /pods/rating Get pods rating. Parameters expected : start end
GET /pods/total_rating Get pods aggregated rating. Parameters expected : start end
GET /pods/metrics/rating Get the rating on a time period, grouped by namespaces and metrics. Parameters expected : start end
GET /pods/<pod>/<aggregator> Get the pods rating by time aggregation. Available aggregator are: daily weekly monthly
GET /pods/<pod>/rating Get the rating for a given pod. Parameters expected : start end
GET /pods/<pod>/total_rating Get the sum of the rating , for a given pod. Parameters expected : start end
GET /pods/<pod>/metrics/<metric>/rating Get the rating on a time period, for givens pod and metric. Parameters expected : start end
GET /pods/<pod>/metrics/<metric>/rating Get the sum of the rating on a time period, for givens pod and metric. Parameters expected : start end

Examples

  • Simple endpoints

No parameters required, call the endpoint, get a response.

$ curl http://127.0.0.1/namespaces
{
    "results":[{"namespace":"kube-system","tenant_id":"default"},{"namespace":"longhorn-system","tenant_id":"default"},{"namespace":"monitoring","tenant_id":"default"},{"namespace":"rating","tenant_id":"default"},{"namespace":"unspecified","tenant_id":"default"}],"total":5

}
  • Endpoints with url parameters

The endpoints using this method will be labelled [URL].

We'll use /metrics/<metric>/<aggregator> as an exemple here.

In this query, the time range is handled by the aggregator, and the parameters are sent through the url.

# We use  the 'daily' aggregator for the example.
$ curl http://127.0.0.1/metrics/co2-simulation-eu/daily
{"results":[{"value":15.07968}],"total":1}}
  • Endpoints with time range (TR)

The endpoints using this method will be labelled [TR].

For this example, /metrics/<metric>/rating is a perfect choice. There's no time range specified in this query, so we need to specify it using url encoded parameters. The default value for those is from two hours to now.

$ curl http://127.0.0.1/metrics/co2-simulation-eu/rating?start=2024-07-10+10%3A22%3A53.604Z&end=2024-07-10+16%3A22%3A53.604Z
{
    "results":[{"frame_begin":"Wed, 10 Jul 2024 10:23:14 GMT", "metric":"co2-simulation-eu","value":0.62832},{"frame_begin":"Wed, 10 Jul 2024 10:23:50 GMT","metric":"co2-simulation-eu","value":0.62833},
    "total": 2
}
  • Endpoint with payload

The endpoints using this method will be labelled [PL].

These endpoints are the hardest to query, from a user perspective. They are generally available for resource handling, such as rules or tenant management. Let's create a RatingRuleModel with cURL as an example:

$ curl -X POST
       -H "Content-Type: application/json"
       -d '{"query_name": "example_query_name","query_group": "example_query_group","query_template: "exmaple_promql_query"}'
       http://127.0.0.1/templates/add

rating-operator-api's People

Contributors

boumedienne7 avatar cherrared avatar hongphuc95 avatar ngohlong avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

cherrared

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.