Skip to content

Commit

Permalink
Add clickhouse destination (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed committed Jun 13, 2024
1 parent 752e259 commit 129f290
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 1 deletion.
65 changes: 65 additions & 0 deletions common/config/clickhouse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package config

import (
"errors"

"github.com/odigos-io/odigos/common"
)

const (
clickhouseEndpoint = "CLICKHOUSE_ENDPOINT"
clickhouseUsername = "CLICKHOUSE_USERNAME"
clickhousePassword = "CLICKHOUSE_PASSWORD"
)

type Clickhouse struct{}

func (c *Clickhouse) DestType() common.DestinationType {
return common.ClickhouseDestinationType
}

func (c *Clickhouse) ModifyConfig(dest ExporterConfigurer, currentConfig *Config) error {
endpoint, exists := dest.GetConfig()[clickhouseEndpoint]
if !exists {
return errors.New("clickhouse endpoint not specified, gateway will not be configured for Clickhouse")
}

username, userExists := dest.GetConfig()[clickhouseUsername]
password, passExists := dest.GetConfig()[clickhousePassword]
if userExists != passExists {
return errors.New("clickhouse username and password must be both specified, or neither")
}

exporterName := "clickhouse/clickhouse-" + dest.GetID()
exporterConfig := GenericMap{
"endpoint": endpoint,
}
if userExists {
exporterConfig["username"] = username
exporterConfig["password"] = password
}

currentConfig.Exporters[exporterName] = exporterConfig
if isTracingEnabled(dest) {
tracesPipelineName := "traces/clickhouse-" + dest.GetID()
currentConfig.Service.Pipelines[tracesPipelineName] = Pipeline{
Exporters: []string{exporterName},
}
}

if isMetricsEnabled(dest) {
metricsPipelineName := "metrics/clickhouse-" + dest.GetID()
currentConfig.Service.Pipelines[metricsPipelineName] = Pipeline{
Exporters: []string{exporterName},
}
}

if isLoggingEnabled(dest) {
logsPipelineName := "logs/clickhouse-" + dest.GetID()
currentConfig.Service.Pipelines[logsPipelineName] = Pipeline{
Exporters: []string{exporterName},
}
}

return nil
}
3 changes: 2 additions & 1 deletion common/config/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ var availableConfigers = []Configer{
&GrafanaCloudLoki{}, &Datadog{}, &NewRelic{}, &Logzio{}, &Prometheus{},
&Tempo{}, &Loki{}, &Jaeger{}, &GenericOTLP{}, &OTLPHttp{}, &Elasticsearch{}, &Quickwit{}, &Signoz{}, &Qryn{},
&OpsVerse{}, &Splunk{}, &Lightstep{}, &GoogleCloud{}, &GoogleCloudStorage{}, &Sentry{}, &AzureBlobStorage{},
&AWSS3{}, &Dynatrace{}, &Chronosphere{}, &ElasticAPM{}, &Axiom{}, &SumoLogic{}, &Coralogix{}, &Causely{}, &Uptrace{}, &Debug{},
&AWSS3{}, &Dynatrace{}, &Chronosphere{}, &ElasticAPM{}, &Axiom{}, &SumoLogic{}, &Coralogix{}, &Clickhouse{},
&Causely{}, &Uptrace{}, &Debug{},
}

type Configer interface {
Expand Down
1 change: 1 addition & 0 deletions common/dests.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
AzureBlobDestinationType DestinationType = "azureblob"
CauselyDestinationType DestinationType = "causely"
ChronosphereDestinationType DestinationType = "chronosphere"
ClickhouseDestinationType DestinationType = "clickhouse"
CoralogixDestinationType DestinationType = "coralogix"
DatadogDestinationType DestinationType = "datadog"
DebugDestinationType DestinationType = "debug"
Expand Down
35 changes: 35 additions & 0 deletions destinations/data/clickhouse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: internal.odigos.io/v1beta1
kind: Destination
metadata:
type: clickhouse
displayName: Clickhouse
category: self hosted
spec:
image: clickhouse.svg
signals:
traces:
supported: true
metrics:
supported: true
logs:
supported: true
fields:
- name: CLICKHOUSE_ENDPOINT
displayName: Endpoint
componentType: input
componentProps:
type: text
required: true
- name: CLICKHOUSE_USERNAME
displayName: Username
componentType: input
componentProps:
type: text
required: false
- name: CLICKHOUSE_PASSWORD
displayName: Password
componentType: input
componentProps:
type: password
required: false
secret: true
1 change: 1 addition & 0 deletions destinations/logos/clickhouse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 129f290

Please sign in to comment.