[WIP] Add tags as labels to prometheus metrics #898

Open
proffalken wants to merge 1 commits from proffalken/feature/680_add_labels_to_prometheus_metrics into master
proffalken commented 3 years ago (Migrated from github.com)
Owner

Description

Fixes #680 - Once working, this should add any tags added in the UI as labels for Prometheus

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files
  • I have performed a self-review of my own code and test it
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Please do not use any external image service. Instead, just paste in or drag and drop the image here and it will be uploaded automatically.

# Description Fixes #680 - Once working, this should add any tags added in the UI as labels for Prometheus ## Type of change Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) ## Checklist - [x] My code follows the style guidelines of this project - [x] I ran ESLint and other linters for modified files - [x] I have performed a self-review of my own code and test it - [x] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings - [ ] My code needed automated testing. I have added them (this is optional task) ## Screenshots (if any) Please do not use any external image service. Instead, just paste in or drag and drop the image here and it will be uploaded automatically.
proffalken commented 3 years ago (Migrated from github.com)
Poster
Owner

@chakflying / @louislam - I'm not sure how to do this in NodeJS, hopefully this is a reasonable start to show the kind of thing I'm trying to achieve?

Instead of

monitor_status{monitor_name="news.bbc.co.uk",monitor_type="http",monitor_url="https://news.bbc.co.uk",monitor_hostname="null",monitor_port="null"} 1

then I should see

monitor_status{monitor_name="news.bbc.co.uk",monitor_type="http",monitor_url="https://news.bbc.co.uk",monitor_hostname="null",monitor_port="null", my_tag_1="my_value_1", my_tag_2="my_value_2"} 1

Does that make sense?

@chakflying / @louislam - I'm not sure how to do this in NodeJS, hopefully this is a reasonable start to show the kind of thing I'm trying to achieve? Instead of ``` monitor_status{monitor_name="news.bbc.co.uk",monitor_type="http",monitor_url="https://news.bbc.co.uk",monitor_hostname="null",monitor_port="null"} 1 ``` then I should see ``` monitor_status{monitor_name="news.bbc.co.uk",monitor_type="http",monitor_url="https://news.bbc.co.uk",monitor_hostname="null",monitor_port="null", my_tag_1="my_value_1", my_tag_2="my_value_2"} 1 ``` Does that make sense?
chakflying commented 3 years ago (Migrated from github.com)
Owner

If that's the data structure you want, you would probably do this:

for (const tag of monitor.tags) {
  this.monitorLabelValues[tag.name] = tag.value
}
If that's the data structure you want, you would probably do this: ```js for (const tag of monitor.tags) { this.monitorLabelValues[tag.name] = tag.value } ```
proffalken commented 3 years ago (Migrated from github.com)
Poster
Owner

Looks like the tags aren't part of the monitor object?

console.log(monitor); returns the following

Monitor {
  beanMeta: BeanMeta {
    noCache: false,
    fetchAs: '',
    alias: '',
    via: '',
    withCondition: '',
    withConditionData: []
  },
  _id: 5,
  _name: 'news.bbc.co.uk',
  _active: 1,
  _userId: 1,
  _interval: 60,
  _url: 'https://news.bbc.co.uk',
  _type: 'http',
  _weight: 2000,
  _hostname: null,
  _port: null,
  _createdDate: '2021-11-09 15:40:17',
  _keyword: null,
  _maxretries: 0,
  _ignoreTls: 0,
  _upsideDown: 0,
  _maxredirects: 10,
  _acceptedStatuscodesJson: '["200-299"]',
  _dnsResolveType: 'A',
  _dnsResolveServer: '1.1.1.1',
  _dnsLastResult: null,
  _retryInterval: 60,
  _pushToken: null,
  _method: 'GET',
  _body: null,
  _headers: null
}

however I'd expect it to include two tags based on the data in the UI:
image

Looks like the tags aren't part of the `monitor` object? `console.log(monitor);` returns the following ``` Monitor { beanMeta: BeanMeta { noCache: false, fetchAs: '', alias: '', via: '', withCondition: '', withConditionData: [] }, _id: 5, _name: 'news.bbc.co.uk', _active: 1, _userId: 1, _interval: 60, _url: 'https://news.bbc.co.uk', _type: 'http', _weight: 2000, _hostname: null, _port: null, _createdDate: '2021-11-09 15:40:17', _keyword: null, _maxretries: 0, _ignoreTls: 0, _upsideDown: 0, _maxredirects: 10, _acceptedStatuscodesJson: '["200-299"]', _dnsResolveType: 'A', _dnsResolveServer: '1.1.1.1', _dnsLastResult: null, _retryInterval: 60, _pushToken: null, _method: 'GET', _body: null, _headers: null } ``` however I'd expect it to include two tags based on the data in the UI: ![image](https://user-images.githubusercontent.com/262545/141107795-31f13472-96a8-404c-8666-17ac79a81d11.png)
This pull request is marked as a work in progress.
Sign in to join this conversation.
Loading…
There is no content yet.