Skip to content

add support for configuring log level using custom rules #301

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Loori-R
Copy link
Contributor

@Loori-R Loori-R commented May 20, 2025

Summary

This pull request adds a "Log level rules" section to the datasource configuration screen. It allows users to define custom rules for dynamically assigning log levels based on field values.

Related issue: #294, #209, #201

How it works

Click "Add rule" to create a new rule. Each rule consists of the following elements:

  1. Enable switch – toggle to enable or disable the rule.
  2. Field name – the log field the rule applies to.
  3. Operator – condition type:
    Equals, Not equal, Matches regex, Less than, Greater than.
  4. Value – the value to compare against.
  5. Log level – level to assign if the rule matches:
    critical, warning, error, info, debug, trace, unknown.
  6. Delete button – removes the rule.

After adding or editing rules, make sure to click "Save & test" to apply the updated configuration.

Rule priority

If multiple rules match, the first one in the list takes precedence.

image

Copy link
Contributor

@dmitryk-dk dmitryk-dk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Loori-R , could you please fix backend part, because of linter

@Loori-R Loori-R force-pushed the issue-294/congifure-log-level branch 2 times, most recently from 0cc4dfe to d28a5bf Compare May 22, 2025 12:31
@Loori-R Loori-R marked this pull request as draft May 22, 2025 13:31
@Loori-R Loori-R force-pushed the issue-294/congifure-log-level branch from d28a5bf to 8f11151 Compare May 22, 2025 13:46
@Loori-R Loori-R marked this pull request as ready for review May 22, 2025 14:12
@Loori-R
Copy link
Contributor Author

Loori-R commented May 22, 2025

@Loori-R , could you please fix backend part, because of linter

Fixed

Copy link
Contributor

@dmitryk-dk dmitryk-dk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments

return {
...query,
step: `${step}s`,
field: HITS_BY_FIELD,
field: uniqFields,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename JSON param to fields because it is an array now

@@ -53,7 +53,7 @@ type Query struct {
IntervalMs int64 `json:"intervalMs"`
MaxLines int `json:"maxLines"`
Step string `json:"step"`
Field string `json:"field"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is better to name the JSON field as fields because it is a slice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants