Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the metrics config api #12670

Merged
merged 4 commits into from
Jul 18, 2023
Merged

Conversation

amnonh
Copy link
Contributor

@amnonh amnonh commented Jan 30, 2023

This series is based on top of the seastar relabel config API.

The series adds a REST API for the configuration, it allows to get and set it.

The API is registered under the V2 prefix and uses the swagger 2.0 definition.

After this series to get the current relabel-config configuration:

    curl -X GET --header 'Accept: application/json' 'http://localhost:10000/v2/metrics-config/'

A set config example:

    curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '[ \
       { \
         "source_labels": [ \
           "__name__" \
         ], \
         "action": "replace", \
         "target_label": "level", \
         "replacement": "1", \
         "regex": "io_que.*" \
       } \
     ]' 'http://localhost:10000/v2/metrics-config/'

This is how it looks like in the UI
image

@scylladb-promoter
Copy link
Contributor

@amnonh
Copy link
Contributor Author

amnonh commented Apr 9, 2023

V2 - A forced push rebase to resolve a conflict

@scylladb-promoter
Copy link
Contributor

@denesb
Copy link
Contributor

denesb commented Apr 11, 2023

CI state FAILURE - https://jenkins.scylladb.com/job/scylla-master/job/scylla-ci/538/

Failed because linker crashed with bus error. Re-kicked.

@scylladb-promoter
Copy link
Contributor

This patch changes the base path of the V2 of the API to be '/'.  That
means that the v2 prefix will be part of the path definition.
Currently, it only affect the config API that is created from code.

The motivation for the change is for Swagger definitions that are read
from a file.  Currently, when using the swagger-ui with a doc path set
to http://localhost:10000/v2 and reading the Swagger from a file swagger
ui will concatenate the path and look for
http://localhost:10000/v2/v2/{path}

Instead, the base path is now '/' and the /v2 prefix will be added by
each endpoint definition.

From the user perspective, there is no change in current functionality.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This patch adds the swagger definition for the metrics API.

Currently, the API defines a get and set of the metric_relabel_config.
Until now, only the configuration API was part of the V2 API.

Now, when other APIs are added, it is possible that another API would be
the first to register. The first to register API is different in the
sense that it does not have a leading ',' to it.

This patch adds an option to mark the config API if it's the first.
This patch adds a metrics API implementation.
The API supports get and set the metric relabel config.

Seastar supports metrics relabeling in runtime, following Prometheus
relabel_config.

Based on metrics and label name, a user can add or remove labels,
disable a metric and set the skip_when_empty flag.

The metrics-config API support such configuration to be done using the
RestFull API.

As it's a new API it is placed under the V2 path.

After this patch the following API will be available
'http://localhost:10000/v2/metrics-config/' GET/POST.

For example:
To get the current config:
```
curl -X GET --header 'Accept: application/json' 'http://localhost:10000/v2/metrics-config/'
```

To set a config:
```
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '[ \
   { \
     "source_labels": [ \
       "__name__" \
     ], \
     "action": "replace", \
     "target_label": "level", \
     "replacement": "1", \
     "regex": "io_que.*" \
   } \
 ]' 'http://localhost:10000/v2/metrics-config/'
```
@scylladb-promoter
Copy link
Contributor

@amnonh
Copy link
Contributor Author

amnonh commented Jul 17, 2023

@denesb I've pulled rebased to master and tests are passing.

@@ -1140,6 +1140,7 @@ def find_headers(repodir, excluded_dirs):
'api/task_manager_test.cc',
'api/config.cc',
Json2Code('api/api-doc/config.json'),
Json2Code('api/api-doc/metrics.json'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tchaikov FYI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
}).then([&failed](){
if (failed) {
throw bad_param_exception("conflicts found during relabeling");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should try adding more details here, can be a follow-up.

@scylladb-promoter scylladb-promoter merged commit 6961fbc into scylladb:master Jul 18, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants