Trying to add authorization in prometheus.yaml

3,031 views
Skip to first unread message

Anoop Maurya

unread,
Apr 16, 2021, 3:22:04 AM4/16/21
to Prometheus Users
Hi All,

added the authorization section in the below config and it's getting failed on configuration reload:

Configuration Section:
  - job_name: 'kube-metrics'
    scrape_interval: 10s
    metrics_path: /metrics
    scheme: https
    tls_config:
      insecure_skip_verify: true
    authorization:
            type: 'Bearer'
            credentials: 'xxxxxxxxxxxxxx'
    static_configs:
    - targets: ['ip:port','ip:port']

Error:
______________________________________________________________________________________
Apr 16 06:42:57 vm-prd-monms-001 prometheus[28617]: level=error ts=2021-04-16T06:42:57.882Z caller=main.go:668 msg="Error reloading config" err="couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n  line 51: field authorization not found in type config.ScrapeConfig"
Apr 16 06:50:46 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T06:50:46.247Z caller=main.go:887 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
Apr 16 06:50:46 vm-prd-monms-001 prometheus[28617]: level=error ts=2021-04-16T06:50:46.248Z caller=main.go:668 msg="Error reloading config" err="couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n  line 52: field authorization not found in type config.ScrapeConfig"
Apr 16 07:00:21 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T07:00:21.869Z caller=compact.go:507 component=tsdb msg="write block" mint=1618545600000 maxt=1618552800000 ulid=01F3CQNCKYYYJSDYBW0BXZC2TM duration=21.615032011s
Apr 16 07:00:22 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T07:00:22.709Z caller=main.go:887 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
Apr 16 07:00:22 vm-prd-monms-001 prometheus[28617]: level=error ts=2021-04-16T07:00:22.711Z caller=main.go:668 msg="Error reloading config" err="couldn't load configuration (--config.file=\"/etc/prometheus/prometheus.yml\"): parsing YAML file /etc/prometheus/prometheus.yml: yaml: unmarshal errors:\n  line 52: field authorization not found in type config.ScrapeConfig"
Apr 16 07:00:22 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T07:00:22.902Z caller=head.go:824 component=tsdb msg="Head GC completed" duration=1.027801667s
Apr 16 07:00:24 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T07:00:24.309Z caller=checkpoint.go:95 component=tsdb msg="Creating checkpoint" from_segment=7429 to_segment=7445 mint=1618552800000
Apr 16 07:00:50 vm-prd-monms-001 prometheus[28617]: level=info ts=2021-04-16T07:00:50.452Z caller=head.go:921 component=tsdb msg="WAL checkpoint complete" first=7429 last=7445 duration=26.143957718s


not getting what's wrong in this can some one please help in this ?

Thanks and regards
Anoop

Julien Pivotto

unread,
Apr 16, 2021, 3:24:28 AM4/16/21
to Anoop Maurya, Prometheus Users
You are probably using an older version of prometheus. Please upgrade or use the older bearer_token field.

Now that the documentation in the website is versionned so your can look at the specific documentation of your release.

--
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 prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/c7b857d4-1f73-4716-990b-8de3bf855540n%40googlegroups.com.

Anoop Maurya

unread,
Apr 16, 2021, 4:57:10 AM4/16/21
to Prometheus Users
Hi Julien,

Thanks for your response, I'm using the prometheus, version 2.24.1, This seems almost latest version and documentation is also available.
However I'll try with "bearer_token" field and let you know. Please let me know where to use this bearer_token ??

authorization:
             type: 'bearer_token'
             credentials: 'xxxxxxxxxxxxxx'

OR

authorization:
             bearer_token : 'xxxxxxxxxxxxxx'

OR

bearer_token : 'xxxxxxxxxxxxxx'

Julien Pivotto

unread,
Apr 16, 2021, 5:19:31 AM4/16/21
to Anoop Maurya, Prometheus Users
On 16 Apr 01:57, Anoop Maurya wrote:
> Hi Julien,
>
> Thanks for your response, I'm using the *prometheus, version 2.24.1*, This
> seems almost latest version and documentation is also available.
> However I'll try with "bearer_token" field and let you know. Please let me
> know where to use this bearer_token ??
>
> authorization:
> type: 'bearer_token'
> credentials: 'xxxxxxxxxxxxxx'
>
> OR
>
> authorization:
> bearer_token : 'xxxxxxxxxxxxxx'
>
> OR
>
> bearer_token : 'xxxxxxxxxxxxxx'

This one.

The latest is Prometheus 2.26. 2.24 does not support authorization:.





>
>
> On Friday, 16 April, 2021 at 12:54:28 pm UTC+5:30 Julien Pivotto wrote:
>
> > You are probably using an older version of prometheus. Please upgrade or
> > use the older bearer_token field.
> >
> > Now that the documentation in the website is versionned so your can look
> > at the specific documentation of your release.
> >
> > Le ven. 16 avr. 2021 ą 09:22, Anoop Maurya <anoopmau...@gmail.com> a
> > écrit :
> >
> >> Hi All,
> >>
> >> added the authorization section in the below config and it's getting
> >> failed on configuration reload:
> >>
> >> *Configuration Section:*
> >> - job_name: 'kube-metrics'
> >> scrape_interval: 10s
> >> metrics_path: /metrics
> >> scheme: https
> >> tls_config:
> >> insecure_skip_verify: true
> >> authorization:
> >> type: 'Bearer'
> >> credentials: 'xxxxxxxxxxxxxx'
> >> static_configs:
> >> - targets: ['ip:port','ip:port']
> >>
> >> *Error:*
> >>
> >> *______________________________________________________________________________________*
> >> <https://groups.google.com/d/msgid/prometheus-users/c7b857d4-1f73-4716-990b-8de3bf855540n%40googlegroups.com?utm_medium=email&utm_source=footer>
> >> .
> >>
> >
>
> --
> 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 prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/fe9174b2-9f92-43f7-b108-014dd926c20bn%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

Anoop Maurya

unread,
Apr 16, 2021, 5:40:47 AM4/16/21
to Prometheus Users

> The latest is Prometheus 2.26. 2.24 does not support authorization:.

Oh, 
is there any way to pass the token for authorization in v2.24, how to authenticate in v2.24 then ??

Julien Pivotto

unread,
Apr 16, 2021, 6:38:43 AM4/16/21
to Anoop Maurya, Prometheus Users

Anoop Maurya

unread,
Apr 16, 2021, 6:39:41 AM4/16/21
to Prometheus Users

Never mind 
It's working with following:
  - job_name: 'job_name'
    bearer_token_file: file/path/file_name
OR
  - job_name: 'job_name'
    bearer_token: 'xxxxxxxxxxxxxx'

Thanks for your responses.
Reply all
Reply to author
Forward
0 new messages