Skip to content

[BUG] [object Object] is not valid JSON in prometheus metrics #1665

Closed
@shotor

Description

@shotor

What is the bug?
A clear and concise description of the bug.

I added Prometheus as a data source. But when I go to /app/observability-metrics I see a quick flash of the metrics in the sidebar and then the content goes blank with a JS error in the console:

VM206:1 Uncaught (in promise) SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at displayVisualization (observabilityDashboards.plugin.js:1633:114610)
    at observabilityDashboards.chunk.4.js:1:411757
    at Object.fa [as useMemo] (osd-ui-shared-deps.js:435:61568)
    at t.useMemo (osd-ui-shared-deps.js:419:5984)
    at VisualizationContainer (observabilityDashboards.chunk.4.js:1:410467)
    at $i (osd-ui-shared-deps.js:435:57931)
    at Na (osd-ui-shared-deps.js:435:66792)
    at gs (osd-ui-shared-deps.js:435:105389)
    at uc (osd-ui-shared-deps.js:435:96718)

I put a breakpoint in displayVisualization (observabilityDashboards.plugin.js:1633:114610)

And I can see that metaData.userConfigs is a JavaScript object and not a string.

metaData.userConfigs = JSON.parse(metaData.userConfigs)

If I remove the JSON.parse in my Chrome devtools I can see the metrics in the sidebar. When I click a metric it goes blank again because my Chrome devtools is not making the change persistent. Not sure how to do that.

From source:

metaData.userConfigs = JSON.parse(metaData.userConfigs);

An easy fix would be to check if it's already an object. But not sure why the expected value is string.

How can one reproduce the bug?

  1. Add Prometheus metrics datasource
  2. Click on it
  3. Click on Query Data
  4. See error

What is the expected behavior?

It should show the metrics

What is your host/environment?

  • OS: debian12
  • Docker 25.0.5
  • Version 2.12.0

Do you have any additional context?

I'm getting metrics from:

  • cAdvisor
  • Metrics from the Prometheus instance itself

Metadata

Metadata

Labels

bugSomething isn't workingv2.14.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions