Got stuck when trying to configure Grafana Agent with Grafana Cloud

TL;DR How to set up the Agent to push collected data (WAL) to the Grafana Cloud?

I found MKTXP which is Prometheus Exporter for Mikrotik ROS and I’m trying to install that.

I don’t have Grafana nor Prometheus, I want to use Grafana Cloud for the start, so I’m choosing Grafana Agent, using official Docker grafana/agent.

My agent.yaml content is now just this:

- job_name: 'mktxp'
  static_configs:
    - targets: ['mktxp_machine_IP:49090']

My Agent docker containers produce just this:

ts=2022-01-17T19:25:30.6328358Z caller=dedupe.go:112 agent=prometheus instance=71c9ccfc5282247d837d46f624bc1d78 component=remote level=warn remote_name=71c9cc-10dd0b url=http://localhost:9009/api/prom/push msg="Failed to send batch, retrying" err="Post \"http://localhost:9009/api/prom/push\": dial tcp 127.0.0.1:9009: connect: connection refused"

I did Onboarding Walkthrough (Grafana Cloud) where I’ve selected Prometheus but there is no configuration, just a button for downloading the Agent.

I haven’t found any configuration example about setting Cloud API/credentials. So, please tell me, how to set up the Agent to push collected data (WAL) to the Grafana Cloud?

(I’m a newbie in the Grafana ecosystem)

Thanks

is it the same as what I found in my cloud account in section “Prometheus remote_write Configuration”?

remote_write:
- url: https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push
  basic_auth:
    username: 123456
    password: <Your Grafana.com API Key>

… a few lines below:

Shipping metrics with Grafana Agent


To manually configure the Grafana Agent to scrape and remote_write metrics to Grafana Cloud, please consult the Grafana Agent documentation.

… I’m looking to the Grafana Agent docs and there is nothing with Cloud except Kubernetes which I’m not using

Hello,

The github repo you provided says that Prometheus is optional, but that is not correct. In this case, the repo is offloading data into an independent Prometheus instance and then that instance is sending data to Grafana (Cloud). So, to use the examples provided, you will need to setup a Prometheus database and then add that as a datasource to Grafana Cloud.

Hi @aaronshifflett, thanks for the reply.
I have a Prometheus instance in Grafana Cloud but I don’t know how to configure Grafana Agent (local installation) to push the data to the cloud.

About the Prom optionality, MKTXP can provide some stats from its CLI, so that’s why Prometheus is optional but it doesn’t matter now.

There are a few different ways to implement and operate agent-based monitoring, so this will depend on what OS and/or application(s) you want to collect data for.

Some simple example configurations can be found here:

And selecting one of the integrations in the Onboarding Walkthrough as you mentioned will customize the agent config file for those specific metrics, logs, and/or traces. Since there isn’t an available integration for Mikrotik ROS you can either create the config file using the agent docs above or perhaps start with the basic OS integration (such as the Linux node exporter or the Docker integration) and modify the provided config file to scrape the MKTXP exporter. I’m not familiar with the MKTXP exporter but Grafana Agent is a lightweight subset of Prometheus, so if the MKTXP exporter you linked exposes those metrics then the agent should be able to scrape them.

The remote_write url will be the Prometheus endpoint provided in your cloud account portal. You’ll see the username / instance ID provided there as well, and the password will be an API key you create with Metrics Publisher role. You can also open a support ticket from the cloud account portal for additional assistance!

Hi @Melody, thanks.

I want to collect Mikrotik statistics which are prepared by MKTXP into the Prometheus format. My MKTXP collector runs in docker container with ip 172.18.0.5 on port 49090. And next I have an another docker container, Grafana_Agent.

agent.yaml:

scrape_configs:
  - job_name: 'mktxp-test'
    static_configs:
      - targets: ['172.18.0.5:49090']
remote_write:
  - url: https://prometheus-prod-01-eu-west-0.grafana.net/api/prom/push
    basic_auth:
        username: xxxxxx
        password: my_MetricsPublisher_role_API_key

About the integration. When I’m on Onboarding Walkthrough page (mydomain.grafana.net/a/grafana-easystart-app/), there is a section “Configure the agent to forward existing data:”
image
… so I’m selecting Prometheus and this is just what I’ve got:


… which is pointless because I’m already running Grafana Agent.

Okay, thanks to @erict things started to make sense to me … for future reference, one has to be on Grafana Cloud Portal - managing the Stack and there clicking ‘Details’ button on Prometheus did the trick and tells the right user/key and the remote_write snippet.

Also my agent.yaml was missing metrics: and configs: … I found this example agent/agent.yaml at main · grafana/agent · GitHub.

So I’m running now.

2 Likes