Hi Team
What is the best way to add “X-Scope-OrgID” to grafana cloud agent.
We are planning to use Cortex to receive all the data collected by Grafana Cloud Agent.
Our Initial approach was to use Prometheus to pull metrics and then send to cortex ,
I was following this link , Authentication and Authorisation | Cortex (cortexmetrics.io)
As per the document : “When configuring the remote_write
API in Prometheus there is no way to add extra headers. The user and password fields of http Basic auth, or Bearer token, can be used to convey the tenant ID and/or credentials” .
Which means that i need to run Prometheus instance behind nginx reverse proxy.
But now Prometheus instance is replaced by Grafana Cloud Agent , can some one help me the best possible way to add “X-Scope-OrgID” to GCA ?
Hey! Tech lead of the Grafana Agent here.
That Cortex document is a little out of date. Prometheus added support for adding custom headers in 2.25.0, which is included in the Agent’s 0.13.0 release.
You can specify custom headers in the remote_write section:
remote_write:
- url: some-url-for-cortex
headers:
X-Scope-OrgID: new-value
Hope this helps!
1 Like
Hi @rfratto
Thanks for your response .
Do you have any recommendation in adding the headers . I tried adding headers to the file and get the below error while trying to run grafana-cloud-agent .
“error loading config file /etc/grafana-cloud-agent/config.yml: yaml: unmarshal errors:
line 53: field headers not found in type config.plain” .
Below is the grafana-cloud-agent file i am using
server:
log_level: debug
http_listen_port: 12348
grpc_listen_port: 0
prometheus:
wal_directory: /data/grafana-cloud-agent/wal
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
integrations:
agent:
enabled: true
node_exporter:
enabled: true
prometheus_remote_write:
- url: http://Cortexurl:9009/api/prom/push
name: Test
basic_auth :
username: XX
password: XXXX
headers:
name: TCS
I’m having a hard time telling what the problem might be without it being formatted as code and keeping the indentation. I can confirm this works for me:
server:
log_level: info
http_listen_port: 12345
prometheus:
wal_directory: /tmp/agent
global:
scrape_interval: 5s
configs:
- name: test
host_filter: false
scrape_configs:
- job_name: local_scrape
static_configs:
- targets: ['127.0.0.1:12345']
labels:
cluster: 'localhost'
remote_write:
- url: http://localhost:9009/api/prom/push
headers:
name: test
Can you make sure your indentation is correct and that you are running Grafana Agent v0.13.0?
Am afraid it didn’t worked for me and still throws the same error
I | error loading config file /etc/grafana-cloud-agent/confi1.yml: yaml: unmarshal errors:
line 26: field headers not found in type config.plain , i have attached the file which i changed as per your comment .
Also check my initial yaml file