-
Notifications
You must be signed in to change notification settings - Fork 53
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
Logs volume histogram support #343
Conversation
Firstly, this rocks. 👏 Questions:
|
Drone is failing on
|
Adding a filter when clicking on the amplifier on Logs view doesn't work. @slvrtrn is it something we're going to add in a follow-up?
Note that
@gingerwizard We can add
@gingerwizard Could you elaborate? Don't
@bossinc @asimpson Would Grafana team accept a PR exporting these from https://github.com/grafana/grafana/blob/ab53772416659fa845effe4913051e1f829d47e2/public/app/core/logsModel.ts? |
Yes |
const fields: string[] = []; | ||
const metrics: BuilderMetricField[] = []; | ||
// could be undefined or an empty string (if user deselects the field) | ||
if (query.builderOptions.logLevelField) { |
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.
nit: I'd extract it to a separate function and add some tests for it.
import { partition } from 'lodash'; | ||
|
||
/** | ||
* Partially copy-pasted and adjusted to ClickHouse server-side aggregations |
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.
Nevertheless, can we add some tests?
@slvrtrn Can we benefit from Grafana exporting this functionality?
.map((f) => ({ label: f.label, value: f.name })); | ||
if (columns.length) { | ||
columns.push({ | ||
label: '-', |
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.
Are there best practices for Null
values to reset the selection? @bossinc
export const LogLevelFieldEditor = (props: LogLevelEditorProps) => { | ||
const { label, tooltip } = selectors.components.QueryEditor.QueryBuilder.LOG_LEVEL_FIELD; | ||
// TODO: filter by strings, enums? | ||
const columns: SelectableValue[] = (props.fieldsList || []) |
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.
nit: Could you add a few tests for this logic as well?
Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
Let's not merge it yet. |
Chiming in here re:
Let's move forward as is and if/when those pieces get exported we can refactor. |
I've recreated this PR as #352 |
I cannot create a PR on top of an external branch (see #328), so this one contains both changesets.
To make it simpler for reviewing, here is an identical PR based on my fork where I could use #328 as a base branch: https://github.com/slvrtrn/clickhouse-datasource/pull/1/files
Screenshots:
For obvious reasons, I added two new fields if the format is set to LOGS and the builder mode is Table -
timeField
andlogLevelField
. The only thing I could not figure out is how to restrict showing these fields only when the Explore mode is selected.I used core ElasticSearch implementation as a reference, and there is a fair amount of copy-paste from the base repository (mainly from here).
If we could get
LogLevelColor
getThemeColor
getLogVolumeFieldConfig
getIntervalInfo
as a part of the public API, the amount of copy-pasted code will be significantly reduced.
Of course, some tests are in order, but I wanted to collect some general feedback and maybe some insights considering the TODOs in the code.
It works the following way:
timeField
andlogLevelField
. If thetimeField
is set, the supplementary query for logs volumes will be generated and executed.timeField
is set tocreated_at
, iflogLevelField
is set, the generated query looks like this (abbreviations are taken fromLogLevel
enum):NB: here I am avoiding
lower
function usage, so reasonable values forIN
clauses are generated in advance.logLevelField
is NOT set, the generated query looks like this:time
plus all the log-level fields, which are transformed into a data frame per level.