jaegertracing / jaeger-ui

Web UI for Jaeger
http://jaegertracing.io/
Apache License 2.0
1.15k stars 485 forks source link

[Feature]: Allow formatting template variables in link patterns #2487

Open drewcorlin1 opened 2 weeks ago

drewcorlin1 commented 2 weeks ago

Requirement

As a user of jaeger and another logging system (in my case OpenSearch + OpenSearch dasbhoards) I would like to link from traces in my Jaeger UI to logs in my OpenSearch Dashboards UI while filtering on a specific time range.

Problem

I can currently add a filter on trace ID easily (and this is wonderful, thank you everyone who worked on this 😄). I would also like to apply a time range filter into OpenSearch Dashboards to filter to the right time period for my trace, but given that the startTime from Jaeger is a time value in microseconds I am unable to do so.

Proposal

In Grafana I can do this with a data link using the format from:'${__from:date}' where :date formats the value as a date.

My link pattern in Jaeger looks like

{
  "type": "traces",
  "url": "https://mydashboards.com/_dashboards/app/discover#/?_g=(time:(from:'#{startTime}',to:'#{endTime}'))&_a=(index:filebeat-all,query:(language:kuery,query:'#{traceID}'))",
  "text": "Logs"
}

A similar syntax to allow formatting time values to dates (or if there is something else that is compatible with OpenSearch Dashboards that I don't know of that would satisfy my use case).

Let me know if I can provide any more context

Open questions

No response

yurishkuro commented 2 weeks ago

feel free to propose a PR.

However, generally speaking, Grafana's syntax is insufficient in our context, because it only describes the desired output, but doesn't tell you how to interpret the input. When you use it with standard fields like span.StartTime then yes, the input is well defined (microseconds since epoch), but if you use it with an arbitrary span tag then the input value can be in any units and the transformation function either needs to be told what they are or we have to support math expressions to transform the value into units expected by the transform function.

drewcorlin1 commented 2 weeks ago

Ah that's a good callout thank you. Taking inspiration from Grafana, do you think something like #{startTime:date} (maybe with more variants like Grafana has) that either

is too narrowly focused to be a realistic addition?

yurishkuro commented 2 weeks ago

If instead of date[:format] syntax we provide an explicit function with fixed signature then we don't have to compromise. For example, the function can be epoch_micros_to_date_iso

drewcorlin1 commented 2 weeks ago

I'd be happy to make a proposal PR. How are you imagining that would look in the UI config JSON though? I'm not sure I understand exactly how someone would use it

yurishkuro commented 2 weeks ago

"url": "...#{startTime | epoch_micros_to_date_iso}..."