prometheus-rancher-exporter icon indicating copy to clipboard operation
prometheus-rancher-exporter copied to clipboard

Add environment Info to return.

Open Rucknar opened this issue 8 years ago • 7 comments

For running multiple ones of these, we need to either:

  • Prefix environment (compute cluster) name to the stack/service/hostname output
  • Add a new field with the environment listed

As highlighted in https://github.com/infinityworksltd/prom-conf/issues/2

Rucknar avatar May 11 '16 21:05 Rucknar

@JamesBarwell You think this might be an easy one we can knock off?

Rucknar avatar May 11 '16 21:05 Rucknar

Should be easy if we can get the environment name passed into the node process somehow. Could it be made available as an environment variable by adjusting the docker-compose file?

I'm thinking that exposing it as a label would be better than trying to insert it into the variable name. I'd prefer to keep the metric names static, which as far as I'm aware is how every other exporter does it.

JamesBarwell avatar May 16 '16 14:05 JamesBarwell

Indeed, labels are probably the best bet here. We can populate with the details within the API, it should be listed on each object as a parent.

Rucknar avatar May 16 '16 14:05 Rucknar

FYI I'd would like this feature too. In the meantime I worked around it with relabeling:

- job_name: 'rancher-api'
  static_configs:
    - targets:
      - 'prometheus-rancher-exporter:9010' 
      - 'prometheus-rancher-exporter.prometheus-agents.dev.another.org:9010'
      - 'prometheus-rancher-exporter.prometheus-agents.staging.another.org:9010'
      - 'prometheus-rancher-exporter.prometheus-agents.prod.example.org:9010'
  metric_relabel_configs:                                                        
  - source_labels: ['instance']                                                           
    target_label:  'rancher_environment'                                                          
    regex: '(.*)prometheus-agents\.(.*?)\.(example|another)(.*)'              
    replacement:  $2    

In case it helps someone else !

jmatsushita avatar Sep 22 '16 07:09 jmatsushita

I've been experimenting with monitoring multiple environment with a single instance of this service, and having env field out of the box would be great (as would stack and service fields everywhere they're relevant!).

For now I'm doing something similar to @jmatsushita by setting labels via my custom discovery mechanism.

joshbenner avatar Dec 22 '16 16:12 joshbenner

Hi All,

Looking at scoping this one out, i'm after some clarity however on peoples requirements:

@joshbenner @jmatsushita - To confirm, is it the rancher 'environment' that you wish to be populated for each of the metrics? I can't get at the Rancher server details, but it seems i can list the projects. The downside would be, if you wish to monitor projects outside your environment, you would need to supply API credentials with the appropriate privileged against those 'environments'. The smart labels wouldn't then be applicable.

For those using this as part of the community catalog template, this would only handle the prometheus integration with the API. To discover hosts and containers in other environments, you would have to do some manual configuration, can't see a way around this.

Rucknar avatar Jan 09 '17 12:01 Rucknar

+1

yongzhang avatar Dec 15 '17 05:12 yongzhang