We have some stackdriver log entries that look something like this:
{
insertId: "xyz"
jsonPayload: {
countOfApples: 100
// other stuff
}
// other stuff
}
We would like to be able to set up a log-based metric that tells us the total number of apples seen in the past 10 mins (or any alignment period) but I have, thus far, been unable to find a means of doing so despite reading through the documentation.
Attempt 1:
Filter for those log-entries where countOfApples
is specified and create a Counter metric with countOfApples
as a label.
having done this, I can filter based on the countOfApples
being above or below a certain value. I cannot see a means of aggregating based on this value. All the aggregation options seem to apply to the number of log entries matching the filter over the alignment period
Attempt 2:
Filter for those log-entries where countOfApples
is specified and create a distribution metric with the Field Name set to jsonPayload.CountOfApples
This seems to get closer because I can now see the apple count in the metrics explorer but I cannot find the correct combination of Aligner/Reducers to just give me the total number of apples over the period? Selecting Aligner:delta & Reducer:sum results in an error message:
This aggregation does not produce a valid data type for a Line plot type. Click here to switch the aligner to sum and the reducer to 99th percentile
Is it possible to just monitor the total sum of all these values over each alignment period?
countOfApples
over all filtered logs in the interval. So if we have 3 different log messages inside the window with acountOfApples
of 1, 2 and 5 respectively, I'd want to see a metric with a value of 8. – Bertold