Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliasing A Metric #14

Closed
zak-b2c2 opened this issue Oct 24, 2018 · 15 comments
Closed

Aliasing A Metric #14

zak-b2c2 opened this issue Oct 24, 2018 · 15 comments
Labels
backlog Would like it to be implemented enhancement New feature or request help wanted Extra attention is needed wontfix This will not be worked on

Comments

@zak-b2c2
Copy link

Hello again,

Another request. Would it be possible to have alias as well for the metrics? I have barely touched JS or TS in my whole life so don't feel comfortable making changes tbh ...

table_influxdb_logs

Thanks,
Zak

@simPod
Copy link
Owner

simPod commented Oct 24, 2018

Hello @zak-b2c2

Can you describe your use case please?

@zak-b2c2
Copy link
Author

zak-b2c2 commented Oct 24, 2018

Hi Simon,

Use case is very simple. I have two metrics with same name trades.*.BTCUSD. But I pass in additional JSON parameters to each, let's say it's a filter, to differentiate sells from buys:

  • A - {"side":"bid"}
  • C - {"side":"ask"}

trades

Now it's hard to know which is which on the graph (actually it's the legend), so it will be good to give them an alias. Like trades-BTCUSD-bid and trades-BTCUSD-ask

For other datasources, you are able to preset some arbitrary alias, as shown in the first picture above.

I hope that explains it well.

@simPod
Copy link
Owner

simPod commented Oct 24, 2018

Personally I solve this on the server side. And IMO it's the proper solution. Because for one metric, you can actually return n of data series. I would keep the plugin to solve only issues that backend cannot.

The returned series name can be modified by setting "target" value (in docs "target":"upper_75")

@zak-b2c2
Copy link
Author

Fair enough. I guess we have different usage of your datasource. I return one timeserie per metric. I will have a look at changing target. Thanks

@simPod
Copy link
Owner

simPod commented Oct 24, 2018

I usually do so too but sometimes I return two or more targets for one metric. IMO it's more comfortable to manage data and target namings on the server. The same way as you manage metrics etc.

But I'm not saying that there cannot be an usecase for changing target names on the grafana side.

@andig
Copy link
Collaborator

andig commented Nov 13, 2018

Personally I solve this on the server side.

The Prometheus datasource solved this by adding a "Legend format".

@simPod
Copy link
Owner

simPod commented Dec 13, 2018

@andig How would it work in our case?

image

What is {{handler}} supposed to be? And where the values for it are coming from?

@zak-b2c2
Copy link
Author

Actually, one way I've solved this is by putting a new field in the JSON Data box. Just put "alias":"my-alias" and then you resolve it on the DB side

@wallflower
Copy link

I just finished modifying the original simple-json-datasource with this functionality. I will probably be doing some refactoring, but if someone is interesting in my first pass, I guess I could post the code in my repo. There are some advantages to doing client side over server side, such as the abilitiy to use variables in your aliases etc.

@zak-b2c2
Copy link
Author

@wallflower I would be interested in this :)

@stale
Copy link

stale bot commented Jul 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jul 11, 2019
@simPod simPod added enhancement New feature or request help wanted Extra attention is needed pinned and removed wontfix This will not be worked on labels Jul 14, 2019
@andig
Copy link
Collaborator

andig commented Aug 24, 2019

How would it work in our case? ...
What is {{handler}} supposed to be? And where the values for it are coming from?

I do not personally have a use case for this but I think there are a couple of options:

  • implement something like the graph panel series overrides to specify new names, e.g. by mathing on name or pattern ('foo' vs /foo/)
    Screenshot 2019-08-24 at 11 43 44
  • allow something like a JSONPath expression to extract the name from the datasource series response using something like https://www.npmjs.com/package/JSONPath. This would be similar to the {{handler}} example from Prometheus. This could be combined with the first and last option.
  • keep it simple and allow to override a single series' name (probably covers a lot of cases but would be confusing where it doesn't fit)

@simPod simPod added backlog Would like it to be implemented and removed pinned labels Sep 24, 2019
@stale
Copy link

stale bot commented Oct 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Oct 7, 2020
@stale stale bot closed this as completed Oct 14, 2020
@dmak
Copy link

dmak commented Apr 10, 2021

I will appreciate if somebody could explain how to set alias for metrics in Grafana v7.5.2 and plugin v0.2.4. Can it be set via additional JSON data like { "target": "alias_1" }? Does not work for me... Should it be supported by the backend (RRD server in my case)?
image

@simPod
Copy link
Owner

simPod commented Apr 10, 2021

Hi, currently the backend must alias it for you. Nothing is implemented on datasource side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Would like it to be implemented enhancement New feature or request help wanted Extra attention is needed wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

5 participants