On 26/09/2020 14:01, Kevin Cameron wrote:
Thanks Brian,
  when I sanitized my example I should have put in a fake value rather than ip:port, so 1.1.1.1:1234 <http://1.1.1.1:1234> just to clarify that part.

The Target and label part we have in place now and is working well, I have been reading over some of the relabeling and that is the part I am struggling with.  I found some documentation on __param_  but most do not go into full examples and the original job definition I am not the original creator.

The end product I want to generate should look like:

http://1.1.1.1:1234/export?command=script_X&argument=10.20.30.40&target=127.0.0.1:5666

original:
- job_name: 'test_job'
  metrics_path: /export
  scrape_interval: 5m
  scrape_timeout: 15s
  params:
    command: [script_X]
    argument: ['10.20.30.40']
  static_configs:
  - targets: ['127.0.0.1:5666 <http://127.0.0.1:5666/>']
    labels:
      field1: 'text'
      field2: 'text'
      field3: 'text'

  relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: 1.1.1.1:1234 <http://1.1.1.1:1234>

So would the job with the relabel just look like this?
New:
- job_name: 'test_job'
  metrics_path: /export
  scrape_interval: 5m
  scrape_timeout: 15s
  params:
  static_configs:
  - targets: ['127.0.0.1:5666 <http://127.0.0.1:5666/>']
    labels:
      field1: 'text'
      field2: 'text'
      field3: 'text'
      command: 'script_X'
      argument: '10.20.30.40'

relabel_configs:
  - source_labels: [command]
     target_label: __param_command
   - source_labels: [ipaddress]
     target_label: __param_argument
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: 1.1.1.1:1234 <http://1.1.1.1:1234>


That looks fine to me, except it should be "source_labels: [argument]" rather than "source_labels: [ipaddress]".

--
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/bcb93c78-3f82-c077-c145-a33d1ae7ee09%40pobox.com.

Reply via email to