sql_exporter
sql_exporter copied to clipboard
can I add static labels to target?
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:[email protected]: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'
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
See also a more complete request about this here: #58 (allows reusing collectors config accross different targets)
It is missing in https://github.com/free/sql_exporter/blob/master/documentation/sql_exporter.yml