Skip to content

Commit

Permalink
feat(detected_fields): initial plumbing of new endpoint
Browse files Browse the repository at this point in the history
* introduces an `experimental` api prefix
* establishes request/response for detected fields
  • Loading branch information
trevorwhitney committed Mar 27, 2024
1 parent c74d0eb commit 2f8cc43
Show file tree
Hide file tree
Showing 20 changed files with 2,194 additions and 304 deletions.
53 changes: 53 additions & 0 deletions cmd/loki/loki-local-experimental-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
auth_enabled: false

server:
http_listen_port: 3100
grpc_listen_port: 9096

common:
instance_addr: 127.0.0.1
path_prefix: /tmp/loki
storage:
filesystem:
chunks_directory: /tmp/loki/chunks
rules_directory: /tmp/loki/rules
replication_factor: 1
ring:
kvstore:
store: inmemory

query_range:
results_cache:
cache:
embedded_cache:
enabled: true
max_size_mb: 100

schema_config:
configs:
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v12
index:
prefix: index_
period: 24h

frontend:
experimental_apis_enabled: true

ruler:
alertmanager_url: http://localhost:9093

# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
#
# Statistics help us better understand how Loki is used, and they show us performance
# levels for most users. This helps us prioritize features and documentation.
# For more information on what's sent, look at
# https://github.com/grafana/loki/blob/main/pkg/analytics/stats.go
# Refer to the buildReport method to see what goes into a report.
#
# If you would like to disable reporting, uncomment the following lines:
#analytics:
# reporting_enabled: false
12 changes: 12 additions & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -1359,3 +1359,15 @@ func adjustQueryStartTime(maxLookBackPeriod time.Duration, start, now time.Time)
}
return start
}

func (i *Ingester) GetDetectedFields(ctx context.Context, req *logproto.DetectedFieldsRequest) (*logproto.DetectedFieldsResponse, error) {
return &logproto.DetectedFieldsResponse{
Fields: []*logproto.DetectedField{
{
Label: "foo",
Type: logproto.DetectedFieldString,
Cardinality: 1,
},
},
}, nil
}
14 changes: 14 additions & 0 deletions pkg/loghttp/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@ func ParseLabelQuery(r *http.Request) (*logproto.LabelRequest, error) {
req.Query = query(r)
return req, nil
}

func ParseDetectedFieldsQuery(r *http.Request) (*logproto.DetectedFieldsRequest, error) {
req := &logproto.DetectedFieldsRequest{}

start, end, err := bounds(r)
if err != nil {
return nil, err
}
req.Start = &start
req.End = &end

req.Query = query(r)
return req, nil
}
9 changes: 9 additions & 0 deletions pkg/logproto/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,12 @@ func (m *IndexStatsResponse) LoggingKeyValues() []interface{} {
"entries", m.Entries,
}
}

const (
DetectedFieldString DetectedFieldType = 0
DetectedFieldInt DetectedFieldType = 1
DetectedFieldFloat DetectedFieldType = 2
DetectedFieldBoolean DetectedFieldType = 3
DetectedFieldDuration DetectedFieldType = 4
DetectedFieldBytes DetectedFieldType = 5
)
Loading

0 comments on commit 2f8cc43

Please sign in to comment.