Skip to content
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

[VictoriaLogs] Support count unique values #6287

Conversation

lujiajing1126
Copy link
Contributor

@lujiajing1126 lujiajing1126 commented May 16, 2024

Describe Your Changes

In the contemporary logging UI, it is very important to understand the count/distribution of unique values (cardinality) of a given field within the query range.

image

The screenshot shows the SLS product on AliCloud.

For example,

  1. if developers want to check error logs, normally stats for level fields is necessary,
  2. If developers want to filter logs based on logger (Java classes) names, then stats for logger is necessary,

image

Checklist

The following checks are mandatory:

@lujiajing1126 lujiajing1126 marked this pull request as draft May 16, 2024 13:45
@lujiajing1126
Copy link
Contributor Author

lujiajing1126 commented May 16, 2024

Currently, if multiple fields are used, all unique values will be counted in a single map

@lujiajing1126 lujiajing1126 marked this pull request as ready for review May 17, 2024 01:28
Copy link

codecov bot commented May 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 158 lines in your changes are missing coverage. Please review.

Project coverage is 55.18%. Comparing base (8aaa828) to head (f52caf1).
Report is 697 commits behind head on master.

Files Patch % Lines
lib/logstorage/stats_uniq_values_count.go 0.00% 153 Missing ⚠️
lib/logstorage/pipe_stats.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6287      +/-   ##
==========================================
- Coverage   60.37%   55.18%   -5.20%     
==========================================
  Files         411      587     +176     
  Lines       76609    78127    +1518     
==========================================
- Hits        46253    43114    -3139     
- Misses      27794    32030    +4236     
- Partials     2562     2983     +421     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@valyala
Copy link
Collaborator

valyala commented May 22, 2024

@lujiajing1126 , thanks for the pull request! As I understood it correctly, stats uniq_values_count(field_name) works in the way similar to stats by (field_name) count() hits | sort by (hits desc) .

Note also that VictoriaLogs gained support for hits API, which can return the distribution of matching logs over the selected time range, with optional grouping by arbitrary log fields - see these docs.

Do you still think that it is necessary to add uniq_values_count() stats function? If yes, then please rebase the pull request on the latest commit in master branch.

@lujiajing1126
Copy link
Contributor Author

@lujiajing1126 , thanks for the pull request! As I understood it correctly, stats uniq_values_count(field_name) works in the way similar to stats by (field_name) count() hits | sort by (hits desc) .

Note also that VictoriaLogs gained support for hits API, which can return the distribution of matching logs over the selected time range, with optional grouping by arbitrary log fields - see these docs.

Do you still think that it is necessary to add uniq_values_count() stats function? If yes, then please rebase the pull request on the latest commit in master branch.

Thanks for your reply! I think stats by (field_name) count() hits | sort by (hits desc) works well for us. I will close this PR.

@lujiajing1126 lujiajing1126 deleted the support-uniq-values-count branch May 23, 2024 01:26
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.

None yet

2 participants