Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show if pod is currently a master/replica on pod details #389

Closed
gricey432 opened this issue Jan 5, 2024 · 2 comments · Fixed by #390
Closed

Show if pod is currently a master/replica on pod details #389

gricey432 opened this issue Jan 5, 2024 · 2 comments · Fixed by #390
Labels
UNCONFIRMED Initial state. Need's triaged

Comments

@gricey432
Copy link
Contributor

Describe the enhancement you are proposing:

When looking at Pod details to debug performance issues the first thing I usually need to figure out is which pod is the write master.

Looks like there's a metric coming in pg_replication_is_replica which would make this easy to figure out at a glance. I'm assuming that if it's not a replica then it must be the write master, though I'm not sure if that's true in all setups.

I've added this panel myself through the Grafana UI but I just don't know enough about Grafana to make it into a PR; if I just copy out the dashboard json there's hundreds of seemingly unrelated changes.

image

My panel json looks like

{
  "id": 17,
  "gridPos": {
    "x": 0,
    "y": 0,
    "w": 24,
    "h": 2
  },
  "type": "stat",
  "title": "Pod Type",
  "targets": [
    {
      "refId": "A",
      "datasource": {
        "type": "prometheus",
        "uid": "kOjrg6AVk"
      },
      "editorMode": "code",
      "expr": "pg_replication_is_replica{pod=\"[[pod]]\", pg_cluster=\"[[cluster]]\"}",
      "legendFormat": "__auto",
      "range": false,
      "instant": true,
      "exemplar": false,
      "format": "table"
    }
  ],
  "options": {
    "reduceOptions": {
      "values": false,
      "calcs": [
        "lastNotNull"
      ],
      "fields": ""
    },
    "orientation": "auto",
    "textMode": "auto",
    "colorMode": "none",
    "graphMode": "none",
    "justifyMode": "auto",
    "text": {
      "valueSize": 30
    }
  },
  "fieldConfig": {
    "defaults": {
      "mappings": [
        {
          "type": "value",
          "options": {
            "0": {
              "text": "Master",
              "index": 0
            },
            "1": {
              "text": "Standby",
              "index": 1
            }
          }
        }
      ],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          }
        ]
      },
      "color": {
        "mode": "thresholds"
      }
    },
    "overrides": []
  },
  "datasource": {
    "uid": "kOjrg6AVk",
    "type": "prometheus"
  },
  "pluginVersion": "9.2.20",
  "description": ""
}
@gricey432 gricey432 added the UNCONFIRMED Initial state. Need's triaged label Jan 5, 2024
@gricey432
Copy link
Contributor Author

Also unsure on the best labels to use for consistency.

  • Patroni seems to use Leader and Replica
  • The exporter uses master and replica for labels in prometheus
  • Postgres docs use primary and standby

I'm not sure which pair would be best to show here

@keithf4
Copy link
Collaborator

keithf4 commented Jan 5, 2024

That is the correct metric. There are only two possible valid values so if it's not one it's the other

I would go with Primary/Replica as the labels. That's generally what we've been using.

As for adding a new panel, the easiest way would be exporting out the entire dashboard. The other changes are likely to do with the version of Grafana you're doing the export from. I'm not sure what version of Grafana the latest container dashboards were exported from, but the main ones for pgMonitor are from Grafana 9.2. If you want to stick with the other dashboard versions, you'll have to install that version of Grafana to do your changes and export from there. Otherwise you're pretty much making that the new minimum version of Grafana supported once you export from a newer version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UNCONFIRMED Initial state. Need's triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants