We are currently having a dashboard in gen2 UI that make use of builtin:containers.cpu.usagePercent to show not only the application pod CPU usage but also the pod count.
timeseries {
// for total usage, user and system cpu usage are added
userCpuUsage = avg(dt.containers.cpu.usage_user_time)
, systemCpuUsage = avg(dt.containers.cpu.usage_system_time)
// cpu logical counts are the fallback, if the throttling ratio doesn't exist
, cpuLogicalCount = avg(dt.containers.cpu.logical_cores)
}
// filter statement ...
// leftOuter join allows the throttling ratio to be null
| join [
timeseries {
throttlingRatio = avg(dt.containers.cpu.throttling_ratio)
// same filter statement as above ...
}
], on: { interval, timeframe}, fields: { throttlingRatio}, kind:leftOuter
| fieldsAdd
// sum of system and user cpu usage
numerator = userCpuUsage[] + systemCpuUsage[]
// throttling ratio, or as a fallback cpu logical count.
, denominator = coalesce(throttlingRatio, cpuLogicalCount)
, nanoseconds_per_minute = 60 * 1000 * 1000 * 1000
| fields
interval, timeframe
, cpuUsagePercent = 100.0 * numerator[] / ( denominator[] * nanoseconds_per_minute)
I have tried with the DQL but it can only display the CPU usage percent in total. How can I revise it to display the cpu uage percent on a particular container/pod from a particular kubernetes namespace within a particular kubernetes cluster?
Which does not match the gen2 version. The x-axis becomes time period instead of CPU usage. And the y-axis only displays the contain name. This is what we use in gen2 to display the chart:
The DQL documentation only mention the generic language usage but does not mention what kind of types we can use. I am not sure how to filter with container group instance.
It also does not provide UI like the data explorer that we can choose from the drop down and do not need to learn a new language. I believe these kinds of limitations only hinter us from migrating to the new UI.
@p_devulapalli I have changed the chart type from “Categorical” to “Bar Chart”, only display “CPU limits%” and add in “k8s.pod.name” as the “Split by” criteria and it looks better:
1. I want to display the bar in horizontal instead of vertical.
2. I want to split the bars from the 3 pods into individual columns instead of stacked column.
3. I do not care about the time series. I just want to display the overall (can be average / medium / 90% percentile) CPU usage % within the said time period of the dashboard, say last 2 hours, and the number of pods.
Then I have got 2 follow up questions. In the screenshot I have shown in the first post, the gen2 chart does put the labels (pod and container name) upon the bar itself instead of put them into the y-axis. That can help to save the space for the bar data to display. Does gen3 chart able to do that?
Another question is about the legend at the bottom. In gen2, it will show up to 3 labels and have an entry that shows there are more number of entries. In gen3, however, it only shows 1 label and it does not have the text to remind the users there are more entries. Instead, it only shows a rather non-obvious scroll bar. The bar is so near to the resize icon and it is very easy to misclick it. Is it possible to change that behaviour?
@Hillman Option to display the names on to the bar on Gen3 dashboards is not possible at this time .
The area of legend depends on the size of the view, you might need to adjust the size of the view a bit to adjust the visibility of legend or place them on the right side instead of bottom , I know this may not show up same what you had in Gen2 , alternatively you can turn off the legend as an option
Is there a memory usage version of the DQL that @p_devulapalli provesided for CPU? I’d imagine not, since the kubernetes metric for memory usage appear to be non-existent.
Thanks @p_devulapalli . I was worried that working_sets might not translate exactly to memory used. For instance, if you were to compare it with the legacy memory usage (limits), the data might not match between the two.
@p_devulapalli I have got another question. If I want to display the CPU usage in percent in the form of line chart. Is it possible to do so? I have tried but it returns that The calculated metrics does not support line chart.
@p_devulapalli@FShimaya yup, I have encountered the same issue as well. The old gen2 memory usage percent seems to be lowered than that of working_sets. Also, the working_sets does not reflect the rising trend of the memory usage: