Skip to content

Commit

Permalink
feat: add Trace support in korrel8r (#597)
Browse files Browse the repository at this point in the history
Signed-off-by: Shweta Padubidri <[email protected]>
  • Loading branch information
shwetaap authored Oct 22, 2024
1 parent 6bd346f commit a74b4a5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pkg/controllers/uiplugin/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
Korrel8rConfigMountDir = "/config/"
OpenshiftLoggingNs = "openshift-logging"
OpenshiftNetobservNs = "netobserv"
OpenshiftTracingNs = "openshift-tracing"

annotationPrefix = "observability.openshift.io/ui-plugin-"
)
Expand Down Expand Up @@ -487,14 +488,17 @@ func newKorrel8rService(name string, namespace string) *corev1.Service {

func newKorrel8rConfigMap(name string, namespace string, info UIPluginInfo) (*corev1.ConfigMap, error) {

korrel8rData := map[string]string{"Metric": "thanos-querier", "MetricAlert": "alertmanager-main", "Log": "logging-loki-gateway-http", "Netflow": "loki-gateway-http", "MonitoringNs": "openshift-monitoring", "LoggingNs": OpenshiftLoggingNs, "NetobservNs": OpenshiftNetobservNs}
korrel8rData := map[string]string{"Metric": "thanos-querier", "MetricAlert": "alertmanager-main", "Log": "logging-loki-gateway-http", "Netflow": "loki-gateway-http", "Trace": "tempo-platform-gateway", "MonitoringNs": "openshift-monitoring", "LoggingNs": OpenshiftLoggingNs, "NetobservNs": OpenshiftNetobservNs, "TracingNs": OpenshiftTracingNs}

if info.LokiServiceNames[OpenshiftLoggingNs] != "" {
korrel8rData["Log"] = info.LokiServiceNames[OpenshiftLoggingNs]
}
if info.LokiServiceNames[OpenshiftNetobservNs] != "" {
korrel8rData["Netflow"] = info.LokiServiceNames[OpenshiftNetobservNs]
}
if info.TempoServiceNames[OpenshiftTracingNs] != "" {
korrel8rData["Trace"] = info.TempoServiceNames[OpenshiftTracingNs]
}

var korrel8rConfigYAMLTmpl = template.Must(template.ParseFS(korrel8rConfigYAMLTmplFile, "config/korrel8r.yaml"))
w := bytes.NewBuffer(nil)
Expand Down
5 changes: 4 additions & 1 deletion pkg/controllers/uiplugin/config/korrel8r.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ stores:
- domain: netflow
lokiStack: https://{{ .Netflow }}.{{ .NetobservNs }}.svc:8080
certificateAuthority: ./run/secrets/kubernetes.io/serviceaccount/service-ca.crt
- domain: trace
tempoStack: https://{{ .Trace }}.{{ .TracingNs }}.svc.cluster.local:8080/api/traces/v1/platform/tempo/api/search
certificateAuthority: ./run/secrets/kubernetes.io/serviceaccount/service-ca.crt

include:
- /etc/korrel8r/rules/all.yaml
- /etc/korrel8r/rules/all.yaml
6 changes: 6 additions & 0 deletions pkg/controllers/uiplugin/plugin_info_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type UIPluginInfo struct {
Image string
Korrel8rImage string
LokiServiceNames map[string]string
TempoServiceNames map[string]string
Name string
ConsoleName string
DisplayName string
Expand Down Expand Up @@ -150,6 +151,11 @@ func PluginInfoBuilder(ctx context.Context, k client.Client, plugin *uiv1alpha1.
return nil, err
}

pluginInfo.TempoServiceNames[OpenshiftTracingNs], err = getTempoServiceName(ctx, k, OpenshiftTracingNs)
if err != nil {
return nil, err
}

return pluginInfo, nil

case uiv1alpha1.TypeDistributedTracing:
Expand Down
17 changes: 17 additions & 0 deletions pkg/controllers/uiplugin/troubleshooting_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func createTroubleshootingPanelPluginInfo(plugin *uiv1alpha1.UIPlugin, namespace
DisplayName: "Troubleshooting Panel Console Plugin",
ResourceNamespace: namespace,
LokiServiceNames: make(map[string]string),
TempoServiceNames: make(map[string]string),
ExtraArgs: extraArgs,
LegacyProxies: []osv1alpha1.ConsolePluginProxy{
{
Expand Down Expand Up @@ -158,6 +159,22 @@ func getLokiServiceName(ctx context.Context, k client.Client, ns string) (string
return "", nil
}

func getTempoServiceName(ctx context.Context, k client.Client, ns string) (string, error) {

serviceList := &corev1.ServiceList{}
if err := k.List(ctx, serviceList, client.InNamespace(ns)); err != nil {
return "", err
}

// Accumulate services that contain "gateway" in their names
for _, service := range serviceList.Items {
if strings.Contains(service.Name, "gateway") && service.Labels["app.kubernetes.io/component"] == "gateway" {
return service.Name, nil
}
}
return "", nil
}

func korrel8rClusterRole(name string) *rbacv1.ClusterRole {
korrel8rClusterroleName := name + "-view"
return &rbacv1.ClusterRole{
Expand Down

0 comments on commit a74b4a5

Please sign in to comment.