About my setup:
1 relay node and 1 block producing node.
Node exporter is installed on both the nodes mentioned above.
Grafana is installed on relay node as mentioned here
Following is the output of the ports relay node is listening on :
tcp 0 0 127.0.0.1:12788 0.0.0.0:* LISTEN 76978/cardano-node
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 575/systemd-resolve
tcp 0 0 0.0.0.0:22490 0.0.0.0:* LISTEN 607/sshd: /usr/sbin
tcp 0 0 x.x.x.x:20800 0.0.0.0:* LISTEN 76978/cardano-node
tcp6 0 0 :::3000 :::* LISTEN 2066/grafana-server
tcp6 0 0 :::22490 :::* LISTEN 607/sshd: /usr/sbin
tcp6 0 0 :::9100 :::* LISTEN 2012/node_exporter
Following is the output of the ports core node is listening on :
tcp 0 0 0.0.0.0:12083 0.0.0.0:* LISTEN 602/sshd: /usr/sbin
tcp 0 0 127.0.0.1:12788 0.0.0.0:* LISTEN 9359/cardano-node
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 571/systemd-resolve
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 9359/cardano-node
tcp 0 0 x.x.x.x:20800 0.0.0.0:* LISTEN 9359/cardano-node
tcp6 0 0 :::12083 :::* LISTEN 602/sshd: /usr/sbin
tcp6 0 0 :::9100 :::* LISTEN 1043542/node_export
Grafana status on relay node :
grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2022-08-22 05:50:53 BST; 3 weeks 0 days ago
Docs: http://docs.grafana.org
Main PID: 2066 (grafana-server)
Tasks: 13 (limit: 19150)
Memory: 120.0M
Running prometheus on local machine with following config
scrape_configs:
job_name: “Relay Node”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:20800”]
job_name: “Relay Node Node Exporter”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:9100”]
job_name: “Core Node”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:20800”]
job_name: “Core Node Node Exporter”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:9100”]
job_name: “Relay Node EKG”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:12788”]
job_name: “Block Producing Node Node Exporter EKG”
scrape_interval: 5s
static_configs:
targets: [“x.x.x.x:12788”]
The job name is added as a label job=<job_name>
to any timeseries scraped from this config.
job_name: “prometheus”
metrics_path defaults to ‘/metrics’
scheme defaults to ‘http’.
static_configs:
targets: [“localhost:9090”]
Problems I am facing :
Following command when executed on relay node doesn’t work as mentioned in the document linked above.
curl -s 127.0.0.1:12788/metrics
<!DOCTYPE html>
<html>
<head>
<title>Not found</title>
</head>
<body>
<code>No handler accepted "/metrics"</code>
After I run grafana on my local machine after running prometheus and try to add new datasource I get following error :
Error reading Prometheus: Get “http://localhost:9090/api/v1/query?query=1%2B1&time=1662965276.513 ”: dial tcp [::1]:9090: connect: connection refused
But when I paste the above URL in the browser it works fine with following output :
{“status”:“success”,“data”:{“resultType”:“scalar”,“result”:[1662965233.712,“2”]}}
My local machine a mac book running Big Sur. Firewall settings seem fine as well.
Can you guys please help me understand what am I missing?
os11k
12 September 2022 13:33
2
Hi! @Prateek_Sachdeva !
You are looking on wrong port, for grafana it should not be EKG, but rather prometheus, like here:
"hasPrometheus": [
"127.0.0.1",
12798
]
So if you are using default port you should curl -s 127.0.0.1:12798/metrics
Where did you install Prometheus? On separate machine(not BP and relay)?
In default configuration prometheus metrics are exposed on loopback ip(127.0.0.1), so cardano node metrics will be accessible only locally from those machines. If you want to get those metrics from other servers, then you need to have something like this:
"hasPrometheus": [
"0.0.0.0",
12798
]
But use it with caution, that will expose your metrics to outside world, so please make sure you have proper FW rules.
I’m not sure, but seems you are running Prometheus on separate machine from Grafana, not sure what is idea behind, but for most setups, I personally would recommend to run it on same box.
Hi @os11k
Thank you taking interest in my post and taking time to help me out.
So after following your suggestion I ran curl command using the exposed IP address and I get expected output.
prateek@relay:~$ curl -s x.x.x.x:20800/metrics
rts_gc_cpu_ms 28869264
cardano_node_metrics_RTS_gcticks_int 960465
cardano_node_metrics_Mem_resident_int 4547563520
rts_gc_mutator_cpu_ms 19264607
rts_gc_num_gcs 219302
rts_gc_init_wall_ms 6
rts_gc_max_bytes_used 1479251176
rts_gc_wall_ms 2083374039
rts_gc_gc_cpu_ms 9604657
rts_gc_par_tot_bytes_copied 361620830376
rts_gc_mutator_wall_ms 2078410313
rts_gc_current_bytes_used 2197980424
cardano_node_metrics_RTS_gcHeapBytes_int 4482662400
cardano_node_metrics_RTS_mutticks_int 1926460
cardano_node_metrics_RTS_gcMajorNum_int 46
rts_gc_num_bytes_usage_samples 46
rts_gc_par_max_bytes_copied 69493397104
cardano_node_metrics_RTS_gcMinorNum_int 219256
cardano_node_metrics_nodeStartTime_int 1661362949
rts_gc_par_avg_bytes_copied 361620830376
cardano_node_metrics_Stat_cputicks_int 2886926
cardano_node_metrics_Stat_threads_int 16
rts_gc_bytes_copied 361620830376
cardano_node_metrics_RTS_gcLiveBytes_int 2197980424
rts_gc_bytes_allocated 7254713777824
rts_gc_peak_megabytes_allocated 4275
rts_gc_cumulative_bytes_used 45751701224
rts_gc_current_bytes_slop 28117752
rts_gc_init_cpu_ms 3
rts_gc_gc_wall_ms 4963725
ekg_server_timestamp_ms 1663446321871
rts_gc_max_bytes_slop 111938752
prateek@relay:~$
Following is the snippet of the testnet-config.json on relay node.
“hasEKG”: 12788,
“hasPrometheus”: [
“x.x.x.x”,
20800
],
I have installed node_exporter on my relay & core node. I have installed prometheus on my local machine and I use the following command to access it :
cd /Users/xyz/cardano_testnet/prometheus/prometheus-2.35.0-rc1.darwin-amd64
./prometheus --config.file=prometheus.yml
I am able to run prometheus successfully on my local macbook and I am able to connect to the node exporters. I have attached the screenshot
I am running grafana on my macbook as well and I access using this url
http://x.x.x.x:3000/?orgId=1
So to answer your last question - prometheus and grafana are running on same machine. I am really confused what I am missing.
I am not still not able to setup the data source on grafana when I run it on my mac book. Attached screenshots of failure to add datasource to grafana and output of the link which grafana complains about after I try it in the same browser.
os11k
17 September 2022 21:02
4
Hi @Prateek_Sachdeva
In your print screen you have typo:
it is: http://localhost:9090
not locahost !
You missed l between a & h.