All posts

Bring your own Grafana

Every NodeRings organization gets its own Grafana, and you can also point your own Grafana at NodeRings with a read-only token. Both only ever show your own VMs and game servers.

Written by NodeRings Inc.

NodeRings Inc. writes these notes. The company runs the marketplace and the agent that stays on the provider’s side of the hypervisor.

Your VMs and game servers already report CPU, memory, disk and network to NodeRings. There are now two ways to look at those metrics in Grafana. You can open a Grafana that NodeRings runs for your organization, straight from the console. Or you can add NodeRings as a Prometheus data source in the Grafana you already run, whether that is on your laptop, in your cluster or on Grafana Cloud.

Both read the same data through the same filter, so the answer to "what can I see" is the same in both: the resources of your organization, and nothing else.

Grafana from the console

Every organization on NodeRings gets its own Grafana organization. Click Open in Grafana on a VM or a game server, or Monitoring in the sidebar, and Grafana opens in a new tab. There is no second password. The console signs you in for that one visit.

Grafana home dashboard for a client organization. Counters for four virtual machines, one game server, five running, zero stopped, and a table of resources with name, type, status, CPU, memory, region, provider and plan.
The home dashboard lists your VMs and game servers by the names you gave them.

The dashboards are ready to use: Home, Virtual machine, Game server and All resources. They work the same for Proxmox, VirtFusion, SolusVM and Pterodactyl, so you never pick a driver. Names come from your console, so a graph says web-01, not a UUID.

Virtual machine dashboard for web-01: status running, uptime two weeks, plan of 2 vCPU, 4 GiB RAM and 80 GiB disk, a CPU usage graph over six hours, memory used against the plan, and disk read and write rates.
One VM: status, plan, CPU, memory against the plan, disk and network.

You can edit. The NodeRings dashboards live in a read-only folder and stay up to date. Save a copy into My dashboards and change whatever you like, or write your own PromQL in Explore. What you can't do is add another data source or reach another organization's Grafana. Members with a read-only role get Grafana's Viewer role.

For providers

A provider organization gets two Grafana organizations.

Infrastructure shows your whole fleet: nodes, the guests running on them, capacity and fleet health. Operators, Administrators, Owners and Viewers can open it.

Provider infrastructure overview: one Proxmox node up, six guests, one game server, node CPU and memory graphs over six hours.
The infrastructure view of a provider: nodes, guests and utilisation.

Business shows the numbers behind the fleet: active customers, active resources by type, region and plan, subscriptions, paid and pending payouts in USD, allocated capacity per node, open tickets and your rating. It is a separate Grafana organization on purpose. Revenue should only be visible to people with billing access, and Grafana can't hide one data source from some members of an organization. Billing, Owner and Viewer roles can open it. Administrators get it read-only.

Provider business overview: 42 active customers, 67 active resources, 68 active subscriptions, revenue, payouts pending, open tickets, resources by type, region and plan, and a rating gauge.
The business view of a provider, in its own Grafana organization.

Bring your own Grafana

If you already run Grafana, you may want NodeRings next to your application metrics, under your own alert rules, or on Grafana Cloud. Add NodeRings as a Prometheus data source:

FieldValue
TypePrometheus
URLhttps://promql.noderings.com/orgs/<your organization id>/
HeaderAuthorization: Bearer <service account token>

The organization is in the URL and the token proves you may read it. You never give Grafana a password. Fly.io does the same thing with its /prometheus/<org>/ endpoint and an organization token, and the model is the same here.

When your Grafana sends a query, NodeRings first checks that the token's service account belongs to the organization in the URL and holds the monitoring permission. Then it adds the list of your VMs and game servers to every part of the query, checks the rewritten query again, and only then asks the metrics store. A query you write yourself, in a dashboard or in Explore, gets the same treatment as ours.

1. Create a read-only role

Open Organization → Members → Roles and create a role named Metrics read-only. Give it one permission, CreateMonitoringLaunch, which sits under monitoring in the permission tree. That is the permission that means "may read this organization's metrics", in our Grafana and in yours.

The built-in Viewer role also has it, but Viewer can read everything else in the organization too. A token that only feeds dashboards should not be able to list your SSH keys.

2. Create a service account and a token

Open Organization → Members → Service accounts, create an account named grafana, give it the Metrics read-only role, and create a token. The token is shown once. Copy it into your Grafana, or into the secret store that feeds it, and nowhere else.

Use one service account per Grafana. When you retire a Grafana, delete its token and nothing else breaks.

3. Find your organization ID

Ask the API with the token you just made:

curl -s https://api.noderings.com/v1/organizations \
  -H "Authorization: Bearer $NODERINGS_TOKEN"

The id of your organization goes into the URL.

4. Add the data source

In Grafana, open Connections → Data sources → Add data source → Prometheus.

  1. Prometheus server URL: https://promql.noderings.com/orgs/<your organization id>/
  2. HTTP headers → Add header: header Authorization, value Bearer <your token>
  3. Optional, under Performance: Prometheus type Mimir
  4. Save & test. Grafana answers "Successfully queried the Prometheus API."
Grafana data source settings named NodeRings, type Prometheus, with the server URL https://promql.noderings.com/orgs/ followed by the organization id, and an HTTP header named Authorization whose value Grafana shows only as configured.
The data source in your own Grafana. Grafana stores the token encrypted and shows it only as configured.

If you provision Grafana from files, this is the same thing as YAML:

# provisioning/datasources/noderings.yaml
apiVersion: 1
datasources:
  - name: NodeRings
    uid: nr-metrics
    type: prometheus
    access: proxy
    url: https://promql.noderings.com/orgs/<your organization id>/
    jsonData:
      httpMethod: POST
      prometheusType: Mimir
      httpHeaderName1: Authorization
    secureJsonData:
      httpHeaderValue1: "Bearer ${NODERINGS_TOKEN}"

Keep uid: nr-metrics. Our dashboards point at that uid, so they work in your Grafana without edits.

5. Check it from a terminal

The endpoint is the Prometheus HTTP API, so curl, promtool and any Prometheus client work too:

curl -s "https://promql.noderings.com/orgs/<your organization id>/api/v1/query" \
  -H "Authorization: Bearer $NODERINGS_TOKEN" \
  --data-urlencode 'query=pve_cpu_usage_ratio * on(name) group_left(display_name) nr_resource_info'

You get one series per Proxmox VM, labelled with the name you gave it in the console. VirtFusion and SolusVM guests use vf_ and svm_ metric names, and game servers use ptero_server_.

6. Use our dashboards, or write your own

Open a dashboard in the Grafana from the console, choose Export → Export as JSON, and import that file into your Grafana. With the nr-metrics uid from step 4, it shows the same panels.

The NodeRings virtual machine dashboard imported into a separate Grafana, showing web-01 running with CPU, memory and disk graphs.
The same Virtual machine dashboard, in a Grafana you run yourself.

Or write PromQL in Explore. Every guest metric carries name="NR-<id>", and nr_resource_info adds the display name, type, region, provider and plan, so you can join on name and get readable legends:

Grafana Explore with the query sum by (display_name) of the network receive rate joined to nr_resource_info, graphing four VMs: db-primary, web-01, web-02 and worker-01.
Network in, per VM, written by hand in Explore.

What the token can and cannot do

Questions

Do I need the Grafana from the console to use my own? No. Either works on its own, and you can use both.

Does it work with Grafana Cloud? Yes. The endpoint is public HTTPS, so a hosted Grafana can reach it like any other Prometheus.

Can I alert on NodeRings metrics? In your own Grafana, yes, with your own contact points. The Grafana from the console has alerting turned off, so it never needs to reach the internet.

Can providers read their business numbers from their own Grafana? Not yet. Your own Grafana reads the infrastructure view. The business view is in the Grafana from the console for now.