Skip to content

Commit

Permalink
Add prometheus as datasource (#125)
Browse files Browse the repository at this point in the history
* add prometheus as datasource


Signed-off-by: YANGDB <yang.db.dev@gmail.com>

---------

Signed-off-by: YANGDB <yang.db.dev@gmail.com>
  • Loading branch information
YANG-DB authored Mar 31, 2024
1 parent 99f3a76 commit bab993d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/opensearch/createPromDB.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion src/otelcollector/otelcol-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ receivers:
- "https://*"

exporters:
logging:
loglevel: info
debug:
otlp:
endpoint: "jaeger:4317"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bab993d

Please sign in to comment.