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

Additional metadata #36

Closed
ldaneliukas opened this issue Jan 9, 2020 · 5 comments
Closed

Additional metadata #36

ldaneliukas opened this issue Jan 9, 2020 · 5 comments

Comments

@ldaneliukas
Copy link
Contributor

We're looking for utilizing exporter_exporter to expose additional metadata about each module that would then be consumed by third-party systems via the JSON response.

Currently, what we're using is labels. I.e. each module has a section of labels that is also exposed via JSON and can then be used by another system which constructs scrape targets for file_sd. Note, these aren't actually added to the metrics themselves by exporter_exporter as it still only acts as a proxy. Would that be something that could be added to exporter_exporter?

E.g.

modules:
  node:
    method: http
    http:
       port: 9100
    labels:
       labelname: labelval
       labelname2: labelval2

and

type moduleConfig struct {
	Method  string                 `yaml:"method"`
	Timeout time.Duration          `yaml:"timeout"`
	Labels  map[string]string      `yaml:"labels"`

That's pretty much it, we're not actually doing anything more than exposing it in the json response.

@tcolgate
Copy link
Collaborator

tcolgate commented Jan 9, 2020

Since they aren't really used by the exporter itself, it does feel a little odd, but I can see some potential uses. My gut instinct is to rename it "metadata", and allow any arbitrary map[string]interface{} to be set.
Unless there is some other way of making use of them I've not considered (maybe exposing them through the exporters own metrics?).
It does feel like this should probably live elsewhere though. e.g. if you are mostly trying to get info about the node the exporter is running on, you probably would be better using a file being read and exposed via the node exporter).

@ldaneliukas
Copy link
Contributor Author

Yeah, that's exactly why I'm asking first. I also thought that naming it metadata would be far better suited for general use and wouldn't mislead people.

As for the use case, we'd be adding the metadata to individual modules, not the whole config for expexp.

For us, this allows us to inject those labels to all metrics of any exporter running on the machine. Helps with tagging services, components, tenants, etc in a multi-tenant use case where Prometheus is shared by many teams that use similar exporters.

I can whip up a PR for metadata as discussed if that's something you see being added.

@tcolgate
Copy link
Collaborator

Here's my thinking (I think).
If you are going to use this to join some labels on to the timeseries later, then probably what you want is a metric that gathers those labels (at least, this is one way of doing it, similar to what kube-state-metrics does).
So you'd have:
expexp_module_labels_unit{module="mymodule" label1="1" label2="2"} = 1
You're either making something like that yourself elsewhere (maybe not literally a metrics, but something like that), and either doing the join elsewhere, or in prom).
Now, if you can write the labels/metadata to the expexp config, you can write it anywhere, and if you can write it anywhere you could just write that metrics directly into a file for node_exporter to push out, then you don't need the feature in expexp at all.

I can still be persuaded, and obviously I don't know your use case.

@tcolgate
Copy link
Collaborator

Going to close this, I'm not sure this would add enough value.

@sebinjohn
Copy link

sebinjohn commented Jun 17, 2021

I came searching for this exact requirement (ie. having the ability to add labels).

Please let me know if I should create a new issue?

Here is my use case

I have two environments for an application

  • staging
  • production

Two scrape jobs are then created on prometheus side to scrape both environment.

by supporting the addition of labels, on the expexp side i will be able to specify the environment from which the metrics are exported. This will remove the need for configuring per environment per application prometheus jobs.

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

3 participants