Changing ports for Grafana agent binary (Hosted Prometheus Metrics)

Hello,

I am trying to integrate Hosted Prometheus Metrics via the grafane agent on my server hosted by o2switch.
I followed the given steps and everything works until I try to run the binary with the config file, it gets killed everytime.

I’ve looked with my hosted service (o2switch) and it seems that Grafana uses the ports 12345 for HTTP and 12346 for gRPC, but those cant be used on my server, instead I can use 443 and 80.
So I was wondering how can I modify this so it can work or is there any other method I could use to get my server statistics on Grafana ?

Than you in advance for any help

Welcome

Which given steps did you follow?

The steps were fisrt to install the binary

curl -O -L "https://github.com/grafana/agent/releases/latest/download/grafana-agent-linux-amd64.zip" \
 && unzip "grafana-agent-linux-amd64.zip" \
 && chmod a+x grafana-agent-linux-amd64

then create the config file :

cat << EOF > ./agent-config.yaml
metrics:
  global:
    scrape_interval: 60s
  configs:
  - name: hosted-prometheus
    scrape_configs:
      - job_name: node
        static_configs:
        - targets: ['localhost:9100']
    remote_write:
      - url: https://prometheus-prod-24-prod-eu-west-2.grafana.net/api/prom/push
        basic_auth:
          username: 1007005
          password: API_KEY
EOF

Then run the command :

./grafana-agent-linux-amd64 --config.file=agent-config.yaml

and I get this output :

ts=2023-05-30T15:00:37.471629235Z caller=server.go:191 level=info msg="server listening on addresses" http=127.0.0.1:12345 grpc=127.0.0.1:12346 http_tls_enabled=false grpc_tls_enabled=false
ts=2023-05-30T15:00:37.472203973Z caller=node.go:85 level=info agent=prometheus component=cluster msg="applying config"
ts=2023-05-30T15:00:37.501422881Z caller=remote.go:180 level=info agent=prometheus component=cluster msg="not watching the KV, none set"
ts=2023-05-30T15:00:37.504513817Z caller=zapadapter.go:78 level=info component=traces msg="Traces Logger Initialized"
ts=2023-05-30T15:00:37.641298261Z caller=reporter.go:103 level=info msg="running usage stats reporter"
ts=2023-05-30T15:00:37.752900404Z caller=wal.go:199 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="replaying WAL, this may take a while" dir=data-agent/30f6e537598157df24324bf836a8ca24/wal
ts=2023-05-30T15:00:37.7950324Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=0 maxSegment=8
ts=2023-05-30T15:00:37.795275964Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=1 maxSegment=8
ts=2023-05-30T15:00:37.795465316Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=2 maxSegment=8
ts=2023-05-30T15:00:37.795596771Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=3 maxSegment=8
ts=2023-05-30T15:00:37.795755388Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=4 maxSegment=8
ts=2023-05-30T15:00:37.795947195Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=5 maxSegment=8
ts=2023-05-30T15:00:37.816258341Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=6 maxSegment=8
ts=2023-05-30T15:00:37.816473527Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=7 maxSegment=8
ts=2023-05-30T15:00:37.816578005Z caller=wal.go:246 level=info agent=prometheus instance=30f6e537598157df24324bf836a8ca24 msg="WAL segment loaded" segment=8 maxSegment=8
ts=2023-05-30T15:00:37.879101788Z caller=dedupe.go:112 agent=prometheus instance=30f6e537598157df24324bf836a8ca24 component=remote level=info remote_name=30f6e5-890c8a url=https://prometheus-prod-24-prod-eu-west-2.grafana.net/api/prom/push msg="Starting WAL watcher" queue=30f6e5-890c8a
ts=2023-05-30T15:00:37.87921059Z caller=dedupe.go:112 agent=prometheus instance=30f6e537598157df24324bf836a8ca24 component=remote level=info remote_name=30f6e5-890c8a url=https://prometheus-prod-24-prod-eu-west-2.grafana.net/api/prom/push msg="Starting scraped metadata watcher"
ts=2023-05-30T15:00:37.879604285Z caller=dedupe.go:112 agent=prometheus instance=30f6e537598157df24324bf836a8ca24 component=remote level=info remote_name=30f6e5-890c8a url=https://prometheus-prod-24-prod-eu-west-2.grafana.net/api/prom/push msg="Replaying WAL" queue=30f6e5-890c8a
Killed

From what I found it’s because the port 12345 is blocked on my server and I was wondering jow to change that

1 Like