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

feat: return real data in detected fields endpoint #12421

Merged
merged 15 commits into from
Apr 2, 2024

Conversation

trevorwhitney
Copy link
Collaborator

What this PR does / why we need it:

This PR calculates real responses for the new experimental detected fields endpoint. It does this in an unsustainable, brute force way by parsing each line (up to a limit) in the querier. Ideally, long term, we'll figure out a way to store this data at ingest, but this is a short term solution to vet the API and data we're surfacing to the UI.

Which issue(s) this PR fixes references:
RE: #12339

@trevorwhitney trevorwhitney requested a review from a team as a code owner April 1, 2024 16:22
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Apr 1, 2024
@github-actions github-actions bot removed the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Apr 1, 2024
@@ -99,17 +99,3 @@ func ParseDetectedLabelsQuery(r *http.Request) (*logproto.DetectedLabelsRequest,
Query: query(r),
}, nil
}

func ParseDetectedFieldsQuery(r *http.Request) (*logproto.DetectedFieldsRequest, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved to query.go in the same package

@@ -617,6 +617,93 @@ func ParseVolumeRangeQuery(r *http.Request) (*VolumeRangeQuery, error) {
}, nil
}

func ParseDetectedFieldsQuery(r *http.Request) (*logproto.DetectedFieldsRequest, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved from labels.go and additional fields populated

@@ -900,18 +906,6 @@ func (q *SingleTenantQuerier) Volume(ctx context.Context, req *logproto.VolumeRe
return seriesvolume.Merge(responses, req.Limit), nil
}

func (q *SingleTenantQuerier) DetectedFields(_ context.Context, _ *logproto.DetectedFieldsRequest) (*logproto.DetectedFieldsResponse, error) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved below DetectedLables so so it was next to the private functions it calls

@trevorwhitney trevorwhitney changed the title Detected fields data feat: return real data in detected fields endpoint Apr 1, 2024
@trevorwhitney trevorwhitney marked this pull request as draft April 1, 2024 21:27
@trevorwhitney
Copy link
Collaborator Author

currently not returning any data in loki-dev-005, will publish for review once it's working

return logproto.DetectedFieldDuration
}

if _, err := humanize.ParseBytes(value); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be a string.Contains like we do for the level label detection. I suspect a small benchmark with some special log line will help. Might also be true for duration.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

Love the direction !

@trevorwhitney
Copy link
Collaborator Author

Alright, got it working locally pointing at loki-dev-005 data

curl http://localhost:3100/loki/api/v1/detected_fields\?end\=1711929720000000000\&query\=%7Bjob%3D%22loki-dev-005%2Fquery-frontend%22%7D+%7C%3D+%22metrics.go%22\&start\=1711929600000000000 -H "X-Scope-OrgID: 29"

{
  "fields": [
    {
      "label": "query_hash",
      "type": "int",
      "cardinality": 14
    },
    {
      "label": "query",
      "type": "string",
      "cardinality": 14
    },
    {
      "label": "cache_stats_results_download_time",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "cache_volume_results_req",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "throughput",
      "type": "bytes",
      "cardinality": 13
    },
    {
      "label": "range_type",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "cache_stats_results_req",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "total_bytes",
      "type": "bytes",
      "cardinality": 15
    },
    {
      "label": "cache_index_hit",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "lines_per_second",
      "type": "int",
      "cardinality": 15
    },
    {
      "label": "cache_index_download_time",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "cache_result_hit",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_chunk_bytes_stored",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_chunk_bytes_fetched",
      "type": "int",
      "cardinality": 11
    },
    {
      "label": "index_post_bloom_filter_chunks",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "queue_time",
      "type": "duration",
      "cardinality": 15
    },
    {
      "label": "cache_chunk_req",
      "type": "int",
      "cardinality": 2
    },
    {
      "label": "limit",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "index_total_chunks",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "length",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "ingester_post_filter_lines",
      "type": "int",
      "cardinality": 5
    },
    {
      "label": "congestion_control_latency",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "shards",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_result_req",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_chunk_download_time",
      "type": "duration",
      "cardinality": 12
    },
    {
      "label": "duration",
      "type": "duration",
      "cardinality": 16
    },
    {
      "label": "cache_chunk_hit",
      "type": "int",
      "cardinality": 2
    },
    {
      "label": "query_type",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "returned_lines",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_volume_results_download_time",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "ingester_chunk_matches",
      "type": "int",
      "cardinality": 2
    },
    {
      "label": "disable_pipeline_wrappers",
      "type": "boolean",
      "cardinality": 1
    },
    {
      "label": "start_delta",
      "type": "duration",
      "cardinality": 16
    },
    {
      "label": "total_lines",
      "type": "int",
      "cardinality": 14
    },
    {
      "label": "ts",
      "type": "string",
      "cardinality": 16
    },
    {
      "label": "traceID",
      "type": "string",
      "cardinality": 15
    },
    {
      "label": "ingester_chunk_compressed_bytes",
      "type": "bytes",
      "cardinality": 2
    },
    {
      "label": "total_bytes_structured_metadata",
      "type": "bytes",
      "cardinality": 14
    },
    {
      "label": "level",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "ingester_chunk_downloaded",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "status",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "sampled",
      "type": "boolean",
      "cardinality": 1
    },
    {
      "label": "ingester_chunk_decompressed_bytes",
      "type": "bytes",
      "cardinality": 5
    },
    {
      "label": "store_chunks_download_time",
      "type": "duration",
      "cardinality": 12
    },
    {
      "label": "index_bloom_filter_ratio",
      "type": "float",
      "cardinality": 1
    },
    {
      "label": "ingester_chunk_head_bytes",
      "type": "bytes",
      "cardinality": 1
    },
    {
      "label": "cache_result_query_length_served",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "post_filter_lines",
      "type": "int",
      "cardinality": 14
    },
    {
      "label": "query_referenced_structured_metadata",
      "type": "boolean",
      "cardinality": 1
    },
    {
      "label": "token_id",
      "type": "string",
      "cardinality": 2
    },
    {
      "label": "ingester_requests",
      "type": "int",
      "cardinality": 2
    },
    {
      "label": "end_delta",
      "type": "duration",
      "cardinality": 15
    },
    {
      "label": "chunk_refs_fetch_time",
      "type": "duration",
      "cardinality": 15
    },
    {
      "label": "splits",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_stats_results_hit",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "caller",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "ingester_chunk_refs",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_index_req",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "component",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "step",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "latency",
      "type": "string",
      "cardinality": 1
    },
    {
      "label": "org_id",
      "type": "int",
      "cardinality": 2
    },
    {
      "label": "cache_volume_results_hit",
      "type": "int",
      "cardinality": 1
    },
    {
      "label": "cache_result_download_time",
      "type": "duration",
      "cardinality": 1
    },
    {
      "label": "total_entries",
      "type": "int",
      "cardinality": 3
    }
  ]
}

@trevorwhitney trevorwhitney marked this pull request as ready for review April 2, 2024 17:46
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@trevorwhitney trevorwhitney enabled auto-merge (squash) April 2, 2024 19:54
@trevorwhitney trevorwhitney merged commit a53a0cc into main Apr 2, 2024
10 checks passed
@trevorwhitney trevorwhitney deleted the detected-fields-data branch April 2, 2024 19:57
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
parse log lines in the querier to return data about detected fields. this is not sustainable long term, but a short term solution to validate the data we want for the frontend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants