Glad it's working.  But JSON should have worked fine (all JSON is valid 
YAML automatically)

[
  {
    "targets": [ "1.2.3.4" ],
    "labels": {
      "env": "prod",
      "__pure_apitoken": "some-api-token",
      "job": "pure_flashblade"
    }
  }
]

That looks OK to me, except you need to remove the "job" here. Also there's 
no need to add "env" since you weren't doing so in the static_configs 
version - although it doesn't do any harm to add it, it will just be 
included in your scraped timeseries.

    - source_labels: [__pure_apitoken]
      target_label: __param_apitoken

That explains how you're providing the apitoken: as a parameter in the 
request URL.

On Tuesday, 12 April 2022 at 16:44:16 UTC+1 [email protected] wrote:

> Converted to yml file.  It is working now.  No more json.
>
> On Tuesday, April 12, 2022 at 10:08:56 AM UTC-5 Andrew Meyer wrote:
>
>> Sorry about that.  Here is the actual config for the pure_flashblade and 
>> pure_flasharray for prometheus.
>>
>>   - job_name: 'pure_flashblade'
>>     #scrape_timeout: 1m
>>     #scrape_interval: 15s
>>     metrics_path: /metrics/flashblade/array
>>     relabel_configs:
>>     # meta label of target address --> get parameter "pure_host"
>>     - source_labels: [__address__]
>>       target_label: __param_endpoint
>>     # label of target api token --> get parameter "pure_apitoken"
>>     - source_labels: [__pure_apitoken]
>>       target_label: __param_apitoken
>>     # display the pure host as the instance label
>>     - source_labels: [__address__]
>>       target_label: instance
>>     # point the exporter to the scraping endpoint of the exporter
>>     - target_label: __address__
>>       replacement: 127.0.0.1:9491 # address of the exporter, in debug 
>> mode
>>                                   # THIS NEEDS TO BE CHANGED TO YOUR 
>> ENVIRONMENT
>>
>>     # Actual pure hosts (without a prometheus endpoint) as targets
>> #    file_sd_configs:
>> #    - files: [ '/etc/prometheus/pure_flashblade_targets.json' ]
>>     static_configs:
>>     - targets: [ "1.2.3.4" ]
>>       labels:
>>         __pure_apitoken: Some-api-token
>>
>> I would like to comment out the static_configs section and move to a 
>> file_sd_configs setup.
>>
>> I have mirrored it after some of the other exporters I did this too, but 
>> falling short on the API token.
>>
>> [
>>   {
>>     "targets": [ "1.2.3.4" ],
>>     "labels": {
>>       "env": "prod",
>>       "__pure_apitoken": "some-api-token",
>>       "job": "pure_flashblade"
>>     }
>>   }
>> ]
>> On Tuesday, April 12, 2022 at 2:07:29 AM UTC-5 Brian Candler wrote:
>>
>>> file_sd_configs (with a YAML/JSON file) and static_configs (with inline 
>>> list of targets) are identical format.  What you've written looks valid; we 
>>> can't really help unless you describe what "having some issues" actually 
>>> means, and how it's different from what you did with static_configs.
>>>
>>> Note that simply adding a target label called "__pure_apitoken" won't 
>>> make any difference to how the scraping is done; it certainly won't pass 
>>> any token to the target in the scrape.  This is true for both 
>>> static_configs and file_sd_configs.
>>>
>>> So I suggest you:
>>> 1. Show your full (working) config with static_configs
>>> 2. Show your non-working config with file_sd_configs
>>> and it will probably be clear what you've done differently in the second 
>>> case.
>>>
>>> On Monday, 11 April 2022 at 23:17:11 UTC+1 [email protected] wrote:
>>>
>>>> This is basically going to be set up as 
>>>>
>>>> file_sd_configs:
>>>> - files: [ '/path/to/file.json' ]
>>>>
>>>> And I will comment out the static config.  But I'm having some issues 
>>>> with the json file.
>>>>
>>>> On Monday, April 11, 2022 at 5:02:16 PM UTC-5 Andrew Meyer wrote:
>>>>
>>>>> So this pure storage.  Here is more details:
>>>>>
>>>>> [
>>>>>   {
>>>>>     "targets": [ "1.2.3.4", "2.3.4.5" ],
>>>>>     "labels": {
>>>>>       "env": "prod",
>>>>>       "__pure_apitoken: API KEY,
>>>>>       "job": "pure_flashblade"
>>>>>     }
>>>>>   }
>>>>> ]
>>>>>
>>>>> On Monday, April 11, 2022 at 3:55:02 PM UTC-5 Brian Candler wrote:
>>>>>
>>>>>> 1. How do you need to provide the API token - as a HTTP header (if so 
>>>>>> what)? As a URL query parameter? Something else?
>>>>>>
>>>>>> 2. What do you mean by "set up dynamic targets"?  What service 
>>>>>> discovery mechanism are you using?
>>>>>>
>>>>>> static_configs and file_sd_configs are the same, when it comes to 
>>>>>> setting labels and targets.
>>>>>>
>>>>>> 3. What relabelling configs do you have?   That "__storage_apitoken" 
>>>>>> label must be rewritten to have some effect.  Otherwise, labels which 
>>>>>> begin 
>>>>>> with double underscore are thrown away 
>>>>>> <https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config>
>>>>>> .
>>>>>>
>>>>>> 4. Aside: you shouldn't set "job" as a target label.  This is added 
>>>>>> automatically by the scrape job itself.
>>>>>>
>>>>>> On Monday, 11 April 2022 at 21:34:00 UTC+1 [email protected] wrote:
>>>>>>
>>>>>>> I am trying to set up dynamic targets for our storage environment.  
>>>>>>> I am able to access it using the static_configs but it requires an API 
>>>>>>> token.
>>>>>>>
>>>>>>> This is what I have currently configured but had to revert back to 
>>>>>>> static_configs.  It wouldn't read the API token at all.
>>>>>>>
>>>>>>> [
>>>>>>>   {
>>>>>>>     "targets": [ "1.2.3.4", "2.3.45" ],
>>>>>>>     "labels": {
>>>>>>>       "env": "prod",
>>>>>>>       "__storage_apitoken": 
>>>>>>> "something-something-something-something",
>>>>>>>       "job": "storage_exporter"
>>>>>>>     }
>>>>>>>   }
>>>>>>> ]
>>>>>>>
>>>>>>

-- 
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/521a1dab-5475-46ae-a706-8442e73d4690n%40googlegroups.com.

Reply via email to