Unleash / unleash-edge

MIT License
48 stars 8 forks source link

Unleash Edge metrics - would like to have appName flow through from client app -> Edge -> metrics exposed by Prometheus endpoint #440

Open YayBurritos opened 6 months ago

YayBurritos commented 6 months ago

Describe the feature request

This request started from a discussion in the Unleash public Slack help channel on March 5, 2024...

In looking at the metrics provided by Unleash Server at /internal-backstage/prometheus, it appears that the feature_toggle_usage_total metric doesn't have any items reported by Unleash Edge (based on the appName label values). I would have expected Edge to communicate this info similar to how the Unleash Proxy does it. I see plenty of feature_toggle_usage_total metrics with appName="{our Unleash Proxy}" , but nothing from Edge.

The http_request_duration_milliseconds metric has items where appName="unleash-edge" , which is good. But would be nice to know which toggles are being used by Edge as well. Am I missing something in the Edge configuration that can make this happen? Thanks!

@ivarconr responded:

Edge is not the consumer of the toggle. You would look for the actual appName in the metrics.

I then questioned:

  1. How do I pass the individual "consumer" names to Edge so that Edge will provide that for the metrics? The "consumer" would be the application that is calling Unleash Edge.
  2. Why does the Proxy send the configured UNLEASH_APP_NAME to upstream Unleash to be included in the metrics since it's not the true "consumer"? Proxy and Edge seem to differ in this regard.

@ivarconr responded to those two questions:

  1. Edge and unleash have seperate Prometheus endpoints per instance. It does not make sense for edge to pass Prometheus data upstream.
  2. Because proxy was a bit strange. It acted more like a regular SDK

Ivar asked for clarification as to what we're looking to accomplish (what problem we're trying to solve). That info is in the Background section below.

Background

We have multiple applications (and multiple environments for each app) using Unleash (Edge and Server) for feature toggles. We build various dashboards in Grafana using Prometheus (and other) data.

For a given feature toggle, it can be helpful to know which applications are actually using it...and possibly how often the toggle is being checked...

Potential Use Cases

Those are just some ideas. We can get the metrics for both Edge and Server into Prometheus and having a single place to view them (Grafana, where most of our other metrics surface) is preferable over having to poke around in the Unleash UI (IMO).

Solution suggestions

I've been looking at the toggle metrics in Unleash UI. Seeing Applications that can be used to filter. Those names align with our applications and do seem to flow through from Edge to the metrics displayed in the Unleash UI. Having those same names as the appName label for the feature_toggle_usage_total metric would likely allow us to address the use case(s) outlined above.

I appreciate the response. If there's anything I can do to help, please let me know. Thanks!

daveleek commented 6 months ago

Hello @YayBurritos and thank you for your contribution! We have recorded this as an idea input for future planning. We might opt for a different solution to the issue, one that matches our architecture in a better way.

YayBurritos commented 5 months ago

Just to add a bit more context here for our specific situation, we have two client applications using Edge:

Each application is instantiating an UnleashClient and passing in a unique appName (so let's just say web-app-123 and mobile-app-123 for the sake of argument).

I understand that it may not make sense for Edge to pass this along to Unleash Server. So to satisfy this particular issue/feature request, maybe the following alternative would work:

That would allow us to know which Edge clients are using our toggles. Thanks!

chriswk commented 5 months ago

So, are you saying that you don't see feature_toggle_usage_total{toggle="SomeToggleName", active="true", appName="web-app-123"} in unleash-server, because as I remember it, Edge forwards appNames it has received metrics for up to unleash-server.

So any usage of Edge by web-app-123, should be reflected in the feature_toggle_usage_total in the unleash-server that Edge is connected to.

I can see the value in being able to see feature_toggle_usage_total on the edge /metrics endpoint as well though, so you could do some grafana magic showing what percentage of traffic is going via edge.

YayBurritos commented 5 months ago

The only appNames that we see in the feature_toggle_usage_total metric from Unleash Server at the /internal-backstage/prometheus endpoint are those that are reported from our backend (dotnet) SDKs.

We aren't seeing any appNames that our frontend (JS) SDKs pass to Edge. And Edge metrics currently don't include a feature_toggle_usage_total metric. (NOTE: We're currently using Edge 17.1.0).

I can see the value in being able to see feature_toggle_usage_total on the edge /metrics endpoint as well though, so you could do some grafana magic showing what percentage of traffic is going via edge.

Yes - that would be great. We could certainly query the feature_toggle_usage_total metric from both Unleash Edge (at /internal-backstage/metrics) & Server (at /internal-backstage/prometheus) and display the information on a Grafana dashboard to better understand our toggle usage if that metric was made available by Edge.

chriswk commented 4 months ago

Hi @YayBurritos - a bit of a delayed answer, but with https://github.com/Unleash/unleash/pull/7210 - Unleash should now include metrics coming from Edge, so you should see feature_toggle_usage_total update based on usage from Edge as well. In addition, I've made #469 to track that we add feature_toggle_usage_total to edge's /internal-backstage/metrics as well.

YayBurritos commented 4 months ago

@chriswk : Is there an anticipated Unleash version for these changes? Looks like Unleash v5.12.7 was created a few hours ago, but this change doesn't appear to be included. Just wondering on the process/timing of PRs being merged to main and then becoming part of an official release. Thanks!

ivarconr commented 4 months ago

@YayBurritos it is included in v6.

(older versions will usually just get patches / bug fixes)

YayBurritos commented 4 months ago

Thanks @ivarconr!

YayBurritos commented 4 months ago

@ivarconr , @chriswk : Sorry guys - another question. How soon after new Unleash versions/releases are the Helm charts updated?

YayBurritos commented 3 months ago

Hi @YayBurritos - a bit of a delayed answer, but with Unleash/unleash#7210 - Unleash should now include metrics coming from Edge, so you should see feature_toggle_usage_total update based on usage from Edge as well. In addition, I've made #469 to track that we add feature_toggle_usage_total to edge's /internal-backstage/metrics as well.

Hey @chriswk - Just wanted to give you a quick update...

We recently upgraded to Unleash Server v6 and now see our appNames flowing from Edge to Server and appearing in the feature_toggle_usage_total metric from Server. This is very helpful!

That said, we do still see value in also being able to see the feature_toggle_usage_total metric exposed by the Edge /internal-backstage/metrics endpoint. It is less of a priority for us now that we have the data from Server, but still would be a nice-to-have.

Thanks so much!