From bab993da9173f6a1f94aa0037659a182ecfe27fd Mon Sep 17 00:00:00 2001 From: YANGDB Date: Sun, 31 Mar 2024 11:43:01 -0700 Subject: [PATCH] Add prometheus as datasource (#125) * add prometheus as datasource Signed-off-by: YANGDB --------- Signed-off-by: YANGDB --- docker-compose.yml | 3 +++ src/opensearch/createPromDB.sh | 30 ++++++++++++++++++++++++++++ src/otelcollector/otelcol-config.yml | 4 +++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/opensearch/createPromDB.sh diff --git a/docker-compose.yml b/docker-compose.yml index 0fdbe2acb5..68dc3bebf9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -779,6 +779,7 @@ services: - node.name=opensearch-node1 - discovery.seed_hosts=opensearch-node1,opensearch-node2 - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 + - plugins.query.datasources.encryption.masterkey=8e3f206ea7c07cc1bfc5cf40 - bootstrap.memory_lock=true # along with the memlock settings below, disables swapping - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # minimum and maximum Java heap size, recommend setting both to 50% of system RAM - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD}" @@ -806,6 +807,7 @@ services: - discovery.seed_hosts=opensearch-node1,opensearch-node2 - cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 - bootstrap.memory_lock=true + - plugins.query.datasources.encryption.masterkey=8e3f206ea7c07cc1bfc5cf40 - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_ADMIN_PASSWORD}" ulimits: @@ -828,6 +830,7 @@ services: expose: - "5601" environment: + vis_type_vega.enableExternalUrls: true OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' depends_on: - opensearch-node1 diff --git a/src/opensearch/createPromDB.sh b/src/opensearch/createPromDB.sh new file mode 100644 index 0000000000..20b94436a1 --- /dev/null +++ b/src/opensearch/createPromDB.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Environment variables for authentication +OPENSEARCH_USERNAME="your_username" +OPENSEARCH_PASSWORD="your_password" + +# The endpoint URL for creating the datasource +ENDPOINT="https://localhost:9200/_plugins/_query/_datasources" + +# The JSON payload +PAYLOAD='{ + "name": "my_prometheus", + "connector": "prometheus", + "properties": { + "prometheus.uri": "http://prometheus:9090" + } +}' + +# Execute the curl command +curl -k -X POST "$ENDPOINT" \ + -u "$OPENSEARCH_USERNAME:$OPENSEARCH_PASSWORD" \ + -H "Content-Type: application/json" \ + -d "$PAYLOAD" + +# Check if the curl command was successful +if [ $? -eq 0 ]; then + echo "Datasource created successfully." +else + echo "Failed to create datasource." +fi diff --git a/src/otelcollector/otelcol-config.yml b/src/otelcollector/otelcol-config.yml index a597c82579..2421c8fe00 100644 --- a/src/otelcollector/otelcol-config.yml +++ b/src/otelcollector/otelcol-config.yml @@ -17,6 +17,8 @@ receivers: - "https://*" exporters: + logging: + loglevel: info debug: otlp: endpoint: "jaeger:4317" @@ -67,7 +69,7 @@ exporters: insecure: true insecure_skip_verify: true otlphttp/prometheus: - endpoint: "http://prometheus:9090/api/v1/otlp" + endpoint: "http://prometheus:9090/metrics" tls: insecure: true