-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
'preserveTags' flag for divideSeries, divideSeriesLists, asPercent #2639
Comments
Perhaps even easier (more useful?) an option to keep the tags of the dividend for these functions, rather than strictly overlapping tags. |
Hi @shanson7, |
Tags go in but they don't come out.
Sure, what format? |
Sorry, I still not sure that I understand what that means. I do not use tags in production, though.
Example input, current output, desired output ? |
Haha, yeah I meant what format do tests take for series/tags. I'll dig it out of the code. |
Ok so let's say we have 2 input series representing the number of requests and the total time taken (divisor and dividend respectively):
Currently, if we do
It would be desirable to maintain the tags like:
You can expand this to |
imho the fact that the resulting series have no tags should be considered a bug, and I agree that we should propagate tags in roughly the same way as we do for other aggregation functions. My suggestion would be that by default all tags of the dividend series should be propagated, along with a new tag to be consistent with the behavior of other aggregation-type functions. We may want to consider also propagating tags on the divisor series that are not present on the dividend, whether by default or with an option flag. Does that seem reasonable? |
I get a little nervous about changing this type of behavior after the fact (bug or not) because some people might be actively working around it and it could break existing dashboards. However, the behavior you describe does sound reasonable to me (backward compatibility aside). |
+1. I'm not too worried about accommodating people who may have worked around this lack of tags, as it is such as obvious bug; also tags are not commonly used yet. But ultimately this is a question for the graphite maintainers (which i'm not part of). Note the asPercent signature: Note that Dan suggests setting a new tag
In that proposal, it is implied that if the same tag keys are set between dividend and divisor, but with different values, dividend wins. Keeping a tag value of one of the series as is, when the other series directly contradicts is, seems like a bad idea.... E.g. imagine a division between:
and
we have the choice between:
2 is probably not that useful (we may drop precisely what distinguishes different series), Dan's idea is actually not so bad (we typically look at a series "with respect to" another, where the "another" is implied and keeping only the former explicit may be good enough.), the 3rd one seems most factually correct because it acknowledges the contribution of both components of the division. but the naive formatting may be hard to decipher if either of the tag values already contain a slash. Anyway, that tangent aside, I note that there's two more options to consider to dan's proposal:
I agree the latter isn't all that useful e.g. in asPercent() when we have multiple distinct dividends and a single divisor, we would want to distinguish based on divident tags; whereas in other cases where we map dividends and divisors 1:1 (this happens in divideSeries, divideSeriesList and certain asPercent invocations), I think "divisor tags only" is just as defensible as "dividend tags only". Thus I think all these modes make sense:
and then i think it would make sense to have an additional flag to control the behavior in the latter 2 cases, in case of tag-matches with value mismatches:
|
We have been using tags for a while now, so I expect many dashboards currently "work" with the existing behavior. I expect many of those will be negatively impacted by a backwards incompatible change (not to mention any code that is making queries using these functions). That being said, I'm not strictly against a backwards incompatible change, it just shouldn't be done lightly. The issue might be significantly more prevalent if you expand it to all functions that aggregate/combine multiple series, e.g multiplySeries or even sum/avg/etc. |
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. |
We plan to provide a concrete proposal for this feature after the holidays |
Looking on how to expand these function signatures is interesting... first of all, looking at the function signature we have today for asPercent, it seems to me that even when trying to not use total, the first node specified will always be assigned to total. See below. am i missing something? how does this work today?
that aside, trying to add the arg at the end, only works in python3 (invalid syntax in py2)
adding the new arg as keyword arg before nodes and trying to set it as kwarg, does not work:
but trying to call it not specifying it as an arg suffers from the same problem as with total (unless I'm missing something)
So the only solution I see is adding it at the end and dropping support for python2. but that seems a bit much to ask. |
@Dieterbe: IMO it's easier to introduce new fuction then, with different arguments. |
Gave this some more thought and discussed a bit internally with some set theory nerds at Grafana ( :) ) First of all, I think figuring out which tags to set on the results may become much easier if the division (and the "as-percenting") function matches up dividends and divisors by joining them on tags, so we may want to introduce tag-join-based versions of these functions at some point. I note that divideSeries, divideSeriesList and asPercent functions are not tag aware. they simply match dividends and divisors in the order they were provided, without regard for which tags they have (at this point i would like to ask you @shanson7 , do you do anything special to make this work for you? as in, how do you assure you have the right pairs being matched up? Do you sort the dividend and divisorList somehow, or do you rely on them being sorted already?) Additionally, or because of the former, I'm not excited about introducing a new set of functions that replicate the current ones (although possibly merge divideSeries and divideSeriesLists into one), for the sole reason of being able to pass extra parameters to control how labels are set on the outputs. That's just messy. Thus, I'm hopeful we can simply agree on 1 behavior which we would consider sane and good enough, which doesn't require any flags, nor worries about backwards compatibility because we can just see it as bugfix for the current lack of tags setting. So, my proposal is simply that we tweak divideSeries, divideSeriesLists, and asPercent, such that each output series gets all tags from the dividend, as well as tags from the divisor that have keys that weren't present in the divisor, as well as an
How does this sound ? |
one more thing.. there is no precedent for something like For consistency then, let me retract the aggregatedBy proposal, and instead do something like: series.tags['divideSeries'] = 'divideSeries' I don't see it as particularly useful, but many other series do it, so ... |
Yes, we use
This sounds reasonable. Would it still be based on input order or would there be tag matching?
Ditto on not seeing these additional tags as useful. In fact, we often need to work around these tags in grafana by adding
I think that a |
I propose we don't change how the functions match up dividends and divisors. Merely that we fix the tags being set on the results. Tag based joining can eventually be done in a new set of functions (at that point we can also address other things, such as having 1 division function regardless of the number of inputs), but that's another project. |
I'm still a little worried about changing this behavior backwards incompatibly, since I'm not sure where we will be impacted. However, creating a new |
I'm also voting for new and shiny function, why not? |
proliferation of many functions that all work slightly (or not so slightly) differently is not something that leads to an elegant, intuitive user experience. That said, I see how it is a low cost way to introduce new behaviors without breaking compatibility. Introducing functions should be done thoughtfully and ideally the functions should "feel similar" to other existing ones. I'm working on a proposal and will keep you posted. |
Proposal for a tag based division functionintroductionWe desire to write a function that looks something along the lines of:
It is inspired by divideSeries, divideSeriesList and asPercent, with these notes:
At the core, matching of dividends to divisors is done via tags (either manually specified or auto-discovered. see below), and also a key aspect of this function is how it sets tags on the resulting series. (in contrast to the above mentioned functions where tags from divisor and dividend don't make it into the output series. terminology
explanationSo, dividends and divisors are both a seriesList of 1..N series. A basic case would look something like:
How do we match up dividends and divisors? We need a set of join tags. We have 2 choices:
The most simple way, is to
However, there is a benefit to manually specifying the join tags in some special cases. Namely, you can choose to ignore a tag that all series have in common, if it's not relevant for joining (e.g. a "description" tag), looking at any tag of any given dividend and divisor, there are 7 scenarios. We list them below along with possible behaviors.
It's not so hard to envision situations in which we may want a variety of these behaviors.
join tags defaults to the set of tags that are seen across all dividends and divisors, but can be overridden. one of:
one of:
one of:
one of:
|
Btw, i wouldn't commit to implement all the options first go. I would implement at least the default behavior and a couple of the options, but the implementation phase might reveal some of the options would make things too complicated. |
What if you want to divide a number of input series by a single tag-less series (e.g. the result of
Why would we need to assert this? What if there are "extra" tags that would make the result unique? Imagine we had some metric like "CPU usage per process" and we want to divide by the total CPU capacity of the host . Matching on just
Theoretically, these 2 would have the same join key ( |
I will be picking up with @Dieterbe's proposal. @shanson7 and I discussed this and I agree with his comments (#2639 (comment)). So for the path forward, the proposal is what Dieter originally said (#2639 (comment)) with the following changes:
Full options list with changes:
|
Is your feature request related to a problem? Please describe.
Several functions (at least
divideSeries
,divideSeriesLists
, andasPercent
) trash the tags of the inputs. This makes it difficult to use features in grafana that require tags (e.g. "Labels to Fields" transformation) or other functions likegroupByTags
post division.It would be nice to have an option to preserve tags where the dividend and divisor have the same values.
Describe the solution you'd like
Add a flag (default to false for backwards compatibility) to preserve overlapping tags
Describe alternatives you've considered
N/A
The text was updated successfully, but these errors were encountered: