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

can I add static labels to target? #49

Open
farodrig opened this issue Nov 25, 2019 · 3 comments
Open

can I add static labels to target? #49

farodrig opened this issue Nov 25, 2019 · 3 comments

Comments

@farodrig
Copy link

farodrig commented Nov 25, 2019

Hi, I want to add some static labels to target. Is it possible?

ex:

target:
  # Data source name always has a URI schema that matches the driver name. In some cases (e.g. MySQL)
  # the schema gets dropped or replaced to match the driver expected DSN format.
  data_source_name: 'sqlserver://prom_user:prom_password@dbserver1.example.com:1433'

  # Collectors (referenced by name) to execute on the target.
  collectors: [pricing_data_freshness]

  # My static labels
  labels:
    -  my_label: 'my-label-value'
    -  some-another-label: 'another-label-value'
@farodrig farodrig changed the title How can I add static labels to target? can I add static labels to target? Nov 25, 2019
@burningalchemist
Copy link
Contributor

Hi @farodrig,

it's impossible to add static labels to the target afaik, but you can add static labels in the metrics definition. It was merged to master yesterday, so you can define it now within the metrics configuration with static_labels as key/value pair. See the example:

metrics:
  - metric_name: pricing_update_time
    type: gauge
    help: 'Time when prices for a market were last updated.'
    key_labels:
      # Populated from the `market` column of each row.
      - Market
    static_labels:  <-----------
      # Arbitrary key/value pair
      portfolio: income
      testlabel: testvalue
    values: [LastUpdateTime]
    query: |
      SELECT Market, max(UpdateTime) AS LastUpdateTime
      FROM MarketPrices
      GROUP BY Market

@nanawel
Copy link

nanawel commented Mar 24, 2020

See also a more complete request about this here: #58 (allows reusing collectors config accross different targets)

@SPFZ
Copy link

SPFZ commented May 19, 2020

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

No branches or pull requests

4 participants