Skip to content

chore: Modernize mongodb-mixin#1629

Open
mariaalons wants to merge 14 commits into
masterfrom
mariaalons/modernize-mongodb-mixin
Open

chore: Modernize mongodb-mixin#1629
mariaalons wants to merge 14 commits into
masterfrom
mariaalons/modernize-mongodb-mixin

Conversation

@mariaalons

@mariaalons mariaalons commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Update the MongoDB mixin to match the modernized mixins:

  • Replace hand-written dashboard JSON with generated dashboards
  • Add MongoDB Overview dashboard
  • Add conditional MongoDB Logs dashboard (enableLokiLogs flag)
  • Update jsonnetfile to grafonnet v11.4.0
  • Use signals
Screenshot 2026-06-26 at 15 55 27 Screenshot 2026-06-26 at 16 09 19 Screenshot 2026-06-26 at 16 59 27 Screenshot 2026-06-26 at 16 59 43 Screenshot 2026-06-26 at 17 00 16

@cla-assistant

cla-assistant Bot commented Apr 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Apr 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Dasomeone Dasomeone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing myself blind on these queries, going to have to get back to this PR on Monday, but for now here's my comments so far :)

Comment thread mongodb-mixin/.lint Outdated
Comment thread mongodb-mixin/dashboards.libsonnet
Comment thread mongodb-mixin/rows.libsonnet
Comment thread mongodb-mixin/signals/cluster.libsonnet Outdated

@Dasomeone Dasomeone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates Maria! We'll definitely want to update the sample-app in lockstep with this as currently it doesn't cover appropriately to test/validate

Comment thread mongodb-mixin/panels/cluster.libsonnet Outdated
Comment thread mongodb-mixin/panels/cluster.libsonnet
Comment thread mongodb-mixin/panels/cluster.libsonnet
Comment thread mongodb-mixin/rows.libsonnet Outdated
Comment thread mongodb-mixin/README.md Outdated
Comment thread mongodb-mixin/alerts.libsonnet Outdated
Comment thread mongodb-mixin/signals/cluster.libsonnet Outdated
},
replicaSetState: {
name: 'Replica set state',
description: 'An integer between 0 and 10 that represents the replica state of the current member.',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would benefit to a link to the source/definition of what the 0-10 states mean or represent

Comment thread mongodb-mixin/signals/instance.libsonnet
Comment thread mongodb-mixin/alerts.libsonnet
@mariaalons mariaalons marked this pull request as ready for review June 26, 2026 15:04
@mariaalons mariaalons requested a review from a team as a code owner June 26, 2026 15:04

@Dasomeone Dasomeone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great progress, but we'll need to iron out the customAllValue as it's causing some issues. Basically we'll probably want to either have hardcoded values, or a very specific customAllValues just for the logs lib as it currently affects the main mixin, but not the logs lib for whatever reason

Comment on lines +17 to +18
'1': { index: 1, text: 'PRIMARY' },
'2': { index: 2, text: 'SECONDARY' },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two may need/benefit from a slightly more descriptive healthy state, given they already have y-axis that label them as primary/secondary.

I'm thinking perhaps HEALTHY (PRIMARY) or PRIMARY - Healthy, or similar.

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much nicer now, but I just realised I'd forgotten to comment that there's a duplicate "replica set states" on each set. Might want to drop it since it's already in the title

+ g.panel.stat.options.reduceOptions.withCalcs(['lastNotNull'])
+ g.panel.stat.options.withGraphMode('none'),

replicasetVersions:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight nit on column naming here, might benefit from some cleanup so it's not just the label names?

Not 100% sold on this, so feel free to push back :D

Image

)
+ g.panel.timeSeries.standardOptions.withUnit('s'),

replicasetMemberPing:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate primary/secondary in the legends on this panel

Image

Comment on lines +111 to +119
overviewInstanceStates:
commonlib.panels.generic.statusHistory.base.new(
'Instance states',
targets=[signals.overview.replicaSetStateByInstance.asTarget()],
description='Replica set state per instance over time.'
)
+ g.panel.statusHistory.standardOptions.withMappings([replicaSetStateMappings])
+ g.panel.statusHistory.options.withShowValue('auto'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need to adjust the visualisation for this panel slightly, seems a little unwieldy.

Perhaps cleaning up the number display and y axis might help?
Image

Comment thread mongodb-mixin/panels/overview.libsonnet
Comment thread mongodb-mixin/config.libsonnet Outdated
Comment thread mongodb-mixin/panels/instance.libsonnet
Comment thread mongodb-mixin/dashboards.libsonnet
Comment thread mongodb-mixin/config.libsonnet

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire dashboard is broken due to the .+ allvalue currently

@mariaalons

Copy link
Copy Markdown
Contributor Author

@Dasomeone Thank you for the thorough review 🙏 I applied the requested changes 🙇

@Dasomeone Dasomeone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more comments, I think some of this is just due to sample-app loadgen/coverage but the cluster dashboard definitely is still broken


replicasetAvgLag:
commonlib.panels.generic.stat.base.new(
'Average replica set lag',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another legend issue here

Image

Comment on lines +28 to +30
replicasetMembers:
commonlib.panels.generic.stat.base.new(
'Replica set members',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legend issue
Image


replicasetOplogRecoveryWindow:
commonlib.panels.generic.timeSeries.base.new(
'Oplog recovery window',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing service name info or hostname in legend.

No data for the rest of the oplog panels so can't verify, but might extend to all of them
Image

percona_mongodb: 'mongodb_up',
},
signals: {
uptime: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate "uptime" mention in all legends

Image

},
},
},
replicaSetState: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting value mapping issue here, you may need to break out the shards individually

Image

commonlib.panels.generic.stat.base.new(
'Latency',
targets=[signals.instance.commandLatency.asTarget()],
description='Average command latency.'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is latency not covered by the updated sample app?

Image

Comment on lines +60 to +103
description='Average command latency.'
)
+ g.panel.stat.standardOptions.withUnit('µs')
+ g.panel.stat.options.reduceOptions.withCalcs(['lastNotNull'])
+ g.panel.stat.options.withGraphMode('none'),

instanceReplicaSetStateGauge:
commonlib.panels.generic.stat.base.new(
'Current replica set state',
targets=[signals.instance.replicaSetState.asTarget()],
description='Current state of the replica set member.'
)
+ g.panel.stat.standardOptions.withMappings([replicaSetStateMappings])
+ g.panel.stat.standardOptions.withDisplayName('${__field.labels.service_name}')
+ g.panel.stat.options.withGraphMode('none')
+ g.panel.stat.standardOptions.color.withMode('thresholds')
+ g.panel.stat.standardOptions.thresholds.withSteps([
g.panel.stat.standardOptions.threshold.step.withColor('green')
+ g.panel.stat.standardOptions.threshold.step.withValue(null),
g.panel.stat.standardOptions.threshold.step.withColor('green')
+ g.panel.stat.standardOptions.threshold.step.withValue(1),
g.panel.stat.standardOptions.threshold.step.withColor('blue')
+ g.panel.stat.standardOptions.threshold.step.withValue(2),
g.panel.stat.standardOptions.threshold.step.withColor('orange')
+ g.panel.stat.standardOptions.threshold.step.withValue(3),
g.panel.stat.standardOptions.threshold.step.withColor('red')
+ g.panel.stat.standardOptions.threshold.step.withValue(8),
])
+ g.panel.stat.options.reduceOptions.withCalcs(['lastNotNull']),

instanceCommandOps:
commonlib.panels.generic.timeSeries.base.new(
'Command operations',
targets=[
signals.instance.opCountersTotal.asTarget(),
signals.instance.opCountersReplTotal.asTarget(),
signals.instance.ttlDeletedDocuments.asTarget(),
],
description='Rate of command operations by type.'
)
+ withStacking
+ g.panel.timeSeries.standardOptions.withUnit('ops'),

instanceConnections:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing instance detail in legend

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't comment on it throughout, but most if not all the panels in this dashboard are missing instance detail in the legends. A little hard to validate due to sample-app coverage (might need more comprehensive load-gen?)

Image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still largely broken on latest sample-app

Image

Comment on lines +135 to +143
commonlib.panels.generic.timeSeries.base.new(
'Shard services QPS - $shard',
targets=[signals.cluster.shardServicesQps.asTarget()],
description='Queries per second for shard services.'
)
+ withTableLegend
+ g.panel.timeSeries.standardOptions.withUnit('ops')
+ g.panel.timeSeries.panelOptions.withRepeat('shard'),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong here, just wanted to comment and say I like it. Only downside is this can result in some whitespace on odd configurations/amounts of replicasets but that's acceptable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants