# Not able to set-up prometheus module with bearer token, getting 401 unauthorised

**URL:** <https://discuss.elastic.co/t/not-able-to-set-up-prometheus-module-with-bearer-token-getting-401-unauthorised/374469>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [February 13, 2025, 2:57am UTC](https://discuss.elastic.co/t/not-able-to-set-up-prometheus-module-with-bearer-token-getting-401-unauthorised/374469 "2025-02-13T02:57:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhanu\_Praveen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhanu_praveen/32/60395_2.png) [@Bhanu\_Praveen](https://discuss.elastic.co/u/Bhanu_Praveen)\
**Post date:** [February 13, 2025, 2:57am UTC](https://discuss.elastic.co/t/not-able-to-set-up-prometheus-module-with-bearer-token-getting-401-unauthorised/374469/1 "2025-02-13T02:57:26Z")

</div>

Hello,

Not able to set-up prometheus module with bearer token, getting 401 unauthorised

Below is the config:

```auto
metricbeat.modules:
- module: prometheus
  period: 10s
  hosts: ["http://dasda.xde.com:42115"]
  metrics_path: /adaw/actuator/prometheus?tId=df-1a38be998f51
  bearer_token_file: /opt/metricbeat-8.17.2-linux-x86_64/token.txt

```

Getting Below error:

```auto
{"log.level":"error","@timestamp":"2025-02-13T03:38:11.183+0530","log.origin":{"function":"github.com/elastic/beats/v7/metricbeat/mb/module.(*metricSetWrapper).handleFetchError","file.name":"module/wrapper.go","file.line":333},"message":"Error fetching data for metricset prometheus.collector: unable to decode response from prometheus endpoint: unexpected status code 401 from server","service.name":"metricbeat","ecs.version":"1.6.0"}

```

Pls let me know the issue here??
