-
Notifications
You must be signed in to change notification settings - Fork 107
Conversation
expr/func_summarize.go
Outdated
|
||
output := models.Series{ | ||
Target: newName(serie.Target), | ||
QueryPatt: newName(serie.QueryPatt), // Should this match target? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is right. Asking for grafana people expertise
expr/func_summarize.go
Outdated
newEnd = alignedEnd | ||
} | ||
|
||
output := models.Series{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The QA tests fail because I don't use newEnd. The python code sets series.start and series.end to the newStart and newEnd, I'm not sure if it's equivalent to QueryFrom and QueryTo and if we're supposed to modify them.
while they represent different things, they may often end up being the same (but not always)
query from are literally the from and to derived from the query. (or they're defaults of
merged ! :) |
833baf1
to
3b00804
Compare
3b00804
to
11000bb
Compare
|
||
numPoints := int(util.Min(uint32(len(serie.Datapoints)), (start-end)/interval)) | ||
|
||
for ts, i := start, 0; i < numPoints && ts < end; ts += interval { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be thorough, this is different from the python code. To mirror the python code you would remove i < numPoints
from this line.
The only change is that graphite-mt would add an extra NaN value at the end of the results. Adding this would not remove an extra datapoint (only the extra NaN).
From what I've seen Datapoints.[0].Ts is equivalent to series.start so we wouldn't need it. Also since fellow special function perSecond modifies QueryPatt, I'm inclined to think we should be modifying it here. |
yes, processing functions should update QueryPatt similar to PerSecond or others. see also |
No doubt it should be updated, but should they match? Should Target be the resolved series name and QueryPatt be the expression? |
TBH i'm hazy on the details / history but AFAIK they should not necessarily match (though sometimes they might) as explained in the struct documentation I linked to (if you want more info you'll have to dive into the code and see how the attributes are used). can't we just follow the persecond example, where we just wrap around the pre-existing attributes
|
It is following the persecond example, just that the rename is dynamic based on a parameter. No changes needed so far :) |
ok your approach in setting QueryPatt and Target looks good to me. will get back to you later with a more complete review |
expr/func_summarize.go
Outdated
func (s *FuncSummarize) Signature() ([]Arg, []Arg) { | ||
return []Arg{ | ||
ArgSeriesList{val: &s.in}, | ||
ArgString{key: "interval", val: &s.intervalString, validator: []Validator{IsIntervalString}}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC the key attribute is only for arguments that should be made available as a keyword argument.
per http://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.summarize the interval parameter has no key
It doesn't look like this will support all of the documented functions that the graphite version does (e.g. median) |
yep. either we implement those, or we remove the stable flag. |
output := models.Series{ | ||
Target: newName(serie.Target), | ||
QueryPatt: newName(serie.QueryPatt), | ||
Tags: serie.Tags, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the python code also does:
series.tags['summarize'] = intervalString
series.tags['summarizeFunction'] = func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does...which is odd IMO. Tags are something set at ingest and it seems odd to add more tags at query time (non-optionally). I get that this isn't the place to make these sorts of arguments, but it doesn't sit right with me to mess with the tags (especially in the case of name collision).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to make the info about how the series was processed available to functions further down the chain, and the rationale for modifying the tags is that when you run series x
through a function f
you are creating a new series f(x)
, and its tags should identify it and describe how it's different from x
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that, but it means a lot of "reserved" tag names that need to be kept track of and new ones for each function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ Added in
func summarizeValues(serie models.Series, aggFunc batch.AggFunc, interval, start, end uint32) []schema.Point { | ||
out := pointSlicePool.Get().([]schema.Point) | ||
|
||
numPoints := int(util.Min(uint32(len(serie.Datapoints)), (start-end)/interval)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm confused here. the only reason to get the util.Min of these two, is just in case the input series had a low number of points wrt to the requested interval right?
e.g.
1 day worth of 2-hourly data
requesting summarize of 1h.
so this becomes numPoints = min(12,24) = 12
then why in the loop below do we increment by interval (1h), but only 12 times? that would cover only a 12h timerange?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If (serie.Datapoints[i].Ts < ts+interval) is violated, it doesn't increment i. So it would append NaN's for the inbetween. I'll push a test case that shows this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
6bc7ef2
to
03fdc38
Compare
Simple check so we don't consolidate (batch/aggFunc) no points
9a0fbbe
to
1897d08
Compare
a80464c
to
50cbd2f
Compare
Tags added as requested, other comment explained. |
Not sure how important this is, but the python implementation allows |
Turns out this is very important since grafana sometimes uses strings for bools. |
any more details on "sometimes" ? i recently ran into the same problem with sortByName: the graphite docs don't seem to mention quotes for the bool that said, i'd be happy to hear from @DanCech whether we should follow graphite's documentation/spec or what it actually allows... |
Yeah, in grafana if I build up the expression it doesn't use quotes. If I go and change one of the tag values afterwards, it adds the quotes in (not visibly to the user though). |
At least for the moment Graphite doesn't actually enforce any type-checking on parameters, though with the addition of the inline documentation that would now be possible. Because of that what ends up happening is that |
so @DanCech conclusion: MT should support true, 'true', false and 'false' ( and capitalized versions) |
Sounds more like non-empty strings are true, empty is false. Probably similar with 0/non-zero? |
@shanson7 yeah, it appears that's how it would work today, following the Python rules for truthiness https://docs.python.org/2/library/stdtypes.html#truth-value-testing |
We didn't hash out the ArgBool truthiness. I think this change might cause some issues without it. |
let's continue the convo in #867 |
There's a question to be answered before this is ready to merge.
Should the input series have a matching QueryPatt and Target?
Is QueryFrom and QueryTo equivalent to series.start and series.end in the python code?
Also if #833 is merged, there'll be a conflict with the docs/graphite and I'll rebase to squash commits