Skip to content

Commit

Permalink
feat(metrics): allow passing custom labels to prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
users-search-assignment committed Apr 4, 2020
1 parent c370cc9 commit 8585f9d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
9 changes: 5 additions & 4 deletions docs/devguide/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ Additional parameters for the following chosen databases:
| METRICS_PLUGIN_NAME | metrics_plugin_name | Metrics integration to use [prometheus,influx] || |

#### Prometheus
| Environment Variable | Configuration key | Description | Configurable from UI/API | Default value |
|---------------------- |------------------------------------- |-------------------------------------- |-------------------------- |--------------- |
| | prometheus_metrics.push_gateway_url | Url of push gateway || |
| | prometheus_metrics.buckets_sizes | Bucket sizes to configure prometheus || |
| Environment Variable | Configuration key | Description | Configurable from UI/API | Default value |
|---------------------- |------------------------------------- |---------------------------------------------------|-------------------------- |--------------- |
| | prometheus_metrics.push_gateway_url | Url of push gateway || |
| | prometheus_metrics.buckets_sizes | Bucket sizes to configure prometheus || |
| | prometheus_metrics.labels | Labels will be passed to the push gateway || |

#### Influx
| Environment Variable | Configuration key | Description | Configurable from UI/API | Default value |
Expand Down
13 changes: 9 additions & 4 deletions docs/devguide/docs/swagger-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1865,6 +1865,11 @@ components:
buckets_sizes:
type: string
description: Bucket sizes use to configure prometheus.
labels:
description: Labels which will be passed to prometheus push gateway.
type: object
additionalProperties:
type: string
smtp_server:
additionalProperties: false
type: object
Expand Down Expand Up @@ -1922,15 +1927,15 @@ components:
- $ref: '#/components/schemas/benchmark_weights'
server_errors:
description: 5xx server errors benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
client_errors:
description: 4xx server errors benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
rps:
description: requests per second benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
benchmark_weights:
type: object
Expand All @@ -1943,4 +1948,4 @@ components:
description: benchmark factor weight
percentage:
type: number
description: benchmark percentage weight
description: benchmark percentage weight
13 changes: 9 additions & 4 deletions docs/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,11 @@ components:
buckets_sizes:
type: string
description: Bucket sizes use to configure prometheus.
labels:
description: Labels which will be passed to prometheus push gateway.
type: object
additionalProperties:
type: string
smtp_server:
additionalProperties: false
type: object
Expand Down Expand Up @@ -2203,15 +2208,15 @@ components:
- $ref: '#/components/schemas/benchmark_weights'
server_errors:
description: 5xx server errors benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
client_errors:
description: 4xx server errors benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
rps:
description: requests per second benchmark weight
allOf:
allOf:
- $ref: '#/components/schemas/benchmark_weights'
benchmark_weights:
type: object
Expand All @@ -2224,4 +2229,4 @@ components:
description: benchmark factor weight
percentage:
type: number
description: benchmark percentage weight
description: benchmark percentage weight
24 changes: 21 additions & 3 deletions tests/integration-tests/configManager/configHandler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const updateBodyWithTypes = {
},
prometheus_metrics: {
push_gateway_url: 'string_value',
buckets_sizes: 'string_value'
buckets_sizes: 'string_value',
labels: { key1: 'value1', key2: 'value2' }
},
smtp_server: {
from: 'test@mail.com',
Expand Down Expand Up @@ -69,7 +70,8 @@ const requestBody =
},
prometheus_metrics: {
push_gateway_url: 'string_value_push_gateway_url',
buckets_sizes: 'string_value_buckets_sizes'
buckets_sizes: 'string_value_buckets_sizes',
labels: { key1: 'value1', key2: 'value2' }
},
smtp_server: {
from: 'test@mail.com',
Expand Down Expand Up @@ -229,7 +231,23 @@ describe('update and get config', () => {
"body/benchmark_weights should have required property 'percentile_fifty'",
"body/benchmark_weights should have required property 'server_errors'",
"body/benchmark_weights should have required property 'client_errors'",
"body/benchmark_weights should have required property 'rps'" ]);
"body/benchmark_weights should have required property 'rps'"]);
});
});

describe('Update prometheus configuration with labels which are not key value', () => {
it('update config fail with validation type', async () => {
let response = await configRequestCreator.updateConfig({
prometheus_metrics: {
push_gateway_url: 'string_value',
buckets_sizes: 'string_value',
labels: { key1: { innerKey1: 'value1' }, key2: 'value2' }
}
});
should(response.statusCode).eql(400);
should(response.body.message).eql(validationError);
should(response.body.validation_errors).eql([
"body/prometheus_metrics.labels['key1'] should be string"]);
});
});
});
Expand Down

0 comments on commit 8585f9d

Please sign in to comment.