diff --git a/common/config/clickhouse.go b/common/config/clickhouse.go new file mode 100644 index 000000000..23ee4c756 --- /dev/null +++ b/common/config/clickhouse.go @@ -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 +} diff --git a/common/config/root.go b/common/config/root.go index f24583df0..84cac1464 100644 --- a/common/config/root.go +++ b/common/config/root.go @@ -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 { diff --git a/common/dests.go b/common/dests.go index 25c7829ce..30e762d4e 100644 --- a/common/dests.go +++ b/common/dests.go @@ -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" diff --git a/destinations/data/clickhouse.yaml b/destinations/data/clickhouse.yaml new file mode 100644 index 000000000..8b4542c81 --- /dev/null +++ b/destinations/data/clickhouse.yaml @@ -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 diff --git a/destinations/logos/clickhouse.svg b/destinations/logos/clickhouse.svg new file mode 100644 index 000000000..1751ca953 --- /dev/null +++ b/destinations/logos/clickhouse.svg @@ -0,0 +1 @@ + \ No newline at end of file