mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Remove alpha feature toggle lokiDataframeApi (#65918)
loki: remove experimental feature-flag
This commit is contained in:
parent
531caec602
commit
b928fce070
@ -68,7 +68,6 @@ Alpha features might be changed or removed without prior notice.
|
||||
| `publicDashboards` | Enables public access to dashboards |
|
||||
| `publicDashboardsEmailSharing` | Enables public dashboard sharing to be restricted to only allowed emails |
|
||||
| `lokiLive` | Support WebSocket streaming for loki (early prototype) |
|
||||
| `lokiDataframeApi` | Use experimental loki api for WebSocket streaming (early prototype) |
|
||||
| `storage` | Configurable storage for dashboards, datasources, and resources |
|
||||
| `exploreMixedDatasource` | Enable mixed datasource in Explore |
|
||||
| `newTraceView` | Shows the new trace view design |
|
||||
|
@ -29,7 +29,6 @@ export interface FeatureToggles {
|
||||
publicDashboards?: boolean;
|
||||
publicDashboardsEmailSharing?: boolean;
|
||||
lokiLive?: boolean;
|
||||
lokiDataframeApi?: boolean;
|
||||
featureHighlights?: boolean;
|
||||
migrationLocking?: boolean;
|
||||
storage?: boolean;
|
||||
|
@ -78,12 +78,6 @@ var (
|
||||
State: FeatureStateAlpha,
|
||||
Owner: grafanaObservabilityLogsSquad,
|
||||
},
|
||||
{
|
||||
Name: "lokiDataframeApi",
|
||||
Description: "Use experimental loki api for WebSocket streaming (early prototype)",
|
||||
State: FeatureStateAlpha,
|
||||
Owner: grafanaObservabilityLogsSquad,
|
||||
},
|
||||
{
|
||||
Name: "featureHighlights",
|
||||
Description: "Highlight Grafana Enterprise features",
|
||||
|
@ -10,7 +10,6 @@ prometheusAzureOverrideAudience,beta,@grafana/observability-metrics,false,false,
|
||||
publicDashboards,alpha,@grafana/dashboards-squad,false,false,false,false
|
||||
publicDashboardsEmailSharing,alpha,@grafana/dashboards-squad,false,true,false,false
|
||||
lokiLive,alpha,@grafana/observability-logs,false,false,false,false
|
||||
lokiDataframeApi,alpha,@grafana/observability-logs,false,false,false,false
|
||||
featureHighlights,stable,@grafana/grafana-as-code,false,false,false,false
|
||||
migrationLocking,beta,@grafana/backend-platform,false,false,false,false
|
||||
storage,alpha,@grafana/grafana-app-platform-squad,false,false,false,false
|
||||
|
|
@ -51,10 +51,6 @@ const (
|
||||
// Support WebSocket streaming for loki (early prototype)
|
||||
FlagLokiLive = "lokiLive"
|
||||
|
||||
// FlagLokiDataframeApi
|
||||
// Use experimental loki api for WebSocket streaming (early prototype)
|
||||
FlagLokiDataframeApi = "lokiDataframeApi"
|
||||
|
||||
// FlagFeatureHighlights
|
||||
// Highlight Grafana Enterprise features
|
||||
FlagFeatureHighlights = "featureHighlights"
|
||||
|
@ -13,8 +13,6 @@ import (
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
|
||||
func (s *Service) SubscribeStream(_ context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error) {
|
||||
@ -84,15 +82,9 @@ func (s *Service) RunStream(ctx context.Context, req *backend.RunStreamRequest,
|
||||
params := url.Values{}
|
||||
params.Add("query", query.Expr)
|
||||
|
||||
lokiDataframeApi := s.features.IsEnabled(featuremgmt.FlagLokiDataframeApi)
|
||||
|
||||
wsurl, _ := url.Parse(dsInfo.URL)
|
||||
|
||||
if lokiDataframeApi {
|
||||
wsurl.Path = "/loki/api/v2alpha/tail"
|
||||
} else {
|
||||
wsurl.Path = "/loki/api/v1/tail"
|
||||
}
|
||||
wsurl.Path = "/loki/api/v2alpha/tail"
|
||||
|
||||
if wsurl.Scheme == "https" {
|
||||
wsurl.Scheme = "wss"
|
||||
@ -133,11 +125,7 @@ func (s *Service) RunStream(ctx context.Context, req *backend.RunStreamRequest,
|
||||
}
|
||||
|
||||
frame := &data.Frame{}
|
||||
if !lokiDataframeApi {
|
||||
frame, err = lokiBytesToLabeledFrame(message)
|
||||
} else {
|
||||
err = json.Unmarshal(message, &frame)
|
||||
}
|
||||
err = json.Unmarshal(message, &frame)
|
||||
|
||||
if err == nil && frame != nil {
|
||||
next, _ := data.FrameToJSONCache(frame)
|
||||
|
@ -1,52 +0,0 @@
|
||||
package loki
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
)
|
||||
|
||||
type lokiResponse struct {
|
||||
Streams []lokiStream `json:"streams"`
|
||||
}
|
||||
|
||||
type lokiStream struct {
|
||||
Stream data.Labels `json:"stream"`
|
||||
Values [][2]string `json:"values"`
|
||||
}
|
||||
|
||||
func lokiBytesToLabeledFrame(msg []byte) (*data.Frame, error) {
|
||||
rsp := &lokiResponse{}
|
||||
err := json.Unmarshal(msg, rsp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
labelField := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
||||
timeField := data.NewFieldFromFieldType(data.FieldTypeTime, 0)
|
||||
lineField := data.NewFieldFromFieldType(data.FieldTypeString, 0)
|
||||
|
||||
labelField.Name = "__labels" // for now, avoid automatically spreading this by labels
|
||||
timeField.Name = "Time"
|
||||
lineField.Name = "Line"
|
||||
|
||||
for _, stream := range rsp.Streams {
|
||||
label := stream.Stream.String() // TODO -- make it match prom labels!
|
||||
for _, value := range stream.Values {
|
||||
n, err := strconv.ParseInt(value[0], 10, 64)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
ts := time.Unix(0, n)
|
||||
line := value[1]
|
||||
|
||||
labelField.Append(label)
|
||||
timeField.Append(ts)
|
||||
lineField.Append(line)
|
||||
}
|
||||
}
|
||||
|
||||
return data.NewFrame("", labelField, timeField, lineField), nil
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package loki
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLokiFramer(t *testing.T) {
|
||||
t.Run("converting metric name", func(t *testing.T) {
|
||||
msg := []byte(`{"streams":[
|
||||
{"stream":
|
||||
{"job":"node-exporter","metric":"go_memstats_heap_inuse_bytes"},
|
||||
"values":[
|
||||
["1642091525267322910","line1"]
|
||||
]},
|
||||
{"stream":
|
||||
{"job":"node-exporter","metric":"go_memstats_heap_inuse_bytes"},
|
||||
"values":[
|
||||
["1642091525770585774","line2"],
|
||||
["1642091525770585775","line3"]
|
||||
]},
|
||||
{"stream":
|
||||
{"metric":"go_memstats_heap_inuse_bytes","job":"node-exporter"},
|
||||
"values":[
|
||||
["1642091526263785281","line4"]
|
||||
]}
|
||||
]}`)
|
||||
|
||||
frame, err := lokiBytesToLabeledFrame(msg)
|
||||
require.NoError(t, err)
|
||||
|
||||
lines := frame.Fields[2]
|
||||
require.Equal(t, 4, lines.Len())
|
||||
require.Equal(t, "line1", lines.At(0))
|
||||
require.Equal(t, "line2", lines.At(1))
|
||||
require.Equal(t, "line3", lines.At(2))
|
||||
require.Equal(t, "line4", lines.At(3))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user