grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.99k stars 3.46k forks source link

Expected value for ruler external_url #4722

Open james-callahan opened 3 years ago

james-callahan commented 3 years ago

Currently for the ruler external_url I tried putting in the URL of our Grafana installation: e.g. external_url: "https://grafana.example.com". This bubbled through to alertmanager so that the "Source" link leads to https://grafana.example.com/graph?g0.expr=%28sum+by%28thing%29%28count_over_time%28%7Bnamespace%3D%22foo%22%7D+%7C+json+%7C+bar%3D%22maxRetries%22%5B5m%5D%29%29+%3E+0%29&g0.tab=1, which isn't valid.

This url templating (via "/graph?g0.expr=%s&g0.tab=1") appears to be coming via TableLinkForExpression in vendor/github.com/prometheus/prometheus/util/strutil/strconv.go. I don't think this url format makes any sense for Loki ruler alerts.

--> What should be in the the external_url field? My first thought is that it should bring up the Grafana Explore view.

cstyan commented 3 years ago

@dannykopping any thoughts here? AFAICT we're not setting this value for our loki clusters.

In our Cortex clusters we set external_url to the Prometheus instance we have running in that k8s cluster.

dannykopping commented 3 years ago

It's a good question. It should probably go directly to Explore as @james-callahan suggests. I checked one of our alerts sent by the ruler and the source is indeed useless when going to /graph?g0.expr=%s&g0.tab=1.

stale[bot] commented 2 years ago

Hi! This issue has been automatically marked as stale because it has not had any activity in the past 30 days.

We use a stalebot among other tools to help manage the state of issues in this project. A stalebot can be very useful in closing issues in a number of cases; the most common is closing issues or PRs where the original reporter has not responded.

Stalebots are also emotionless and cruel and can close issues which are still very relevant.

If this issue is important to you, please add a comment to keep it open. More importantly, please add a thumbs-up to the original issue entry.

We regularly sort for closed issues which have a stale label sorted by thumbs up.

We may also:

We are doing our best to respond, organize, and prioritize all issues but it can be a challenging task, our sincere apologies if you find yourself at the mercy of the stalebot.

james-callahan commented 2 years ago

Anyone got ideas on how to address this?

pschulten commented 2 years ago

One could rewrite the expression to grafana-syntax in the fronting http server, e.g. with nginx and lua. But this is probably super complicated.

I'm also very interested. We use Cortex as a remote_write target for multiple Prometheis and the same thing applies there, as well.

I think, I'll just rewrite the /graph.* to something generic like https://grafana.example.com/alerting/list for now, which is maybe more helpful than a broken link.

parkedwards commented 2 years ago

yeah we've run into this as well - right now, we've had to leave external_url undefined (and since there isn't a dedicated Loki UI, as there is with Prometheus, we don't have a ton of options as to where we might direct recipients to)

additionally, the way that alertmanager auto-affixes the path route /graph makes it so that we can't send folks to a landing page....especially if /graph doesn't exist in the route tree :(

chewrocca commented 1 year ago

Mimir has grafanaExploreURL in 2.6.0-rc.0. Do you think that could be implemented?

ChristianOps commented 1 year ago

We're having this issue too and trying to find a way to work around this problem.

Not sure what may be different in loki-ruler compared to alert rules added in Grafana managed alerts that also uses our external Alertmanager. Links are properly linking to "Alert rules / View rule" page in Grafana and they are both using the same receiver template in Alertmanager (with GeneratorURL set). Loki-ruler should be able to achieve the same unless I'm missing something here? Anyone knows how that works?

stringang commented 1 year ago

I found the working mechanism of external_url in the source code of version v2.8.2, and it works with recording rules.

https://github.com/grafana/loki/blob/9f809eda70babaf583bdf6bf335a28038f286618/pkg/ruler/base/ruler.go#L79-L82

lyz-code commented 8 months ago

Did anyone get around this issue?

Rohlik commented 5 months ago

We also came across this issue and we are waiting for some fix/workaround.