1
votes

I'm currently learning prometheus and try to visualize its metrics using Grafana and PromQL, but every time I put my queries metrics, it always showing error Cannot read property 'result' of undefined, i searched and tried some queries in internet, and all of them makes no difference. I wonder where i go wrong, since this is my first time using prometheus and grafana, here's some setting i used

First, this is my prometheus config, in .net framework.

public class PrometheusConfig
{
    private static readonly Counter counter = Metrics.CreateCounter("initial_counter", "counter to initiate Prometheus");

    public static void Register(HttpConfiguration config)
    {
        var server = new MetricServer(port: 1234);
        server.Start();

        counter.Inc();
    }

    public static void RegisterFilter(HttpFilterCollection filters)
    {
        filters.Add(new PrometheusFilter());
    }
}

Here my prometheus metrics i want to visualize

this is my grafana data source

enter image description here

and finally, this is my panel graph enter image description here

can someone tell me how to fix this?

1

1 Answers

2
votes

This error usually means that grafana fails to query the API.

In your case, it is because the URL shouldn't include the /metrics. This URL is used for scraping Prometheus internals.

The correct URL should be the base path of Prometheus: http://localhost:1234