Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Expose prometheus metrics on private VM IP (#2105)

Eric Bariaux2731582da3ad
diff --git a/.ci_cd/deploy.sh b/.ci_cd/deploy.sh
index 78c4c120b..123dbf2e3 100644
--- a/.ci_cd/deploy.sh
+++ b/.ci_cd/deploy.sh
@@ -267,6 +267,16 @@ fi
echo "Deleting existing deployment data volume"
docker volume rm or_deployment-data 1>/dev/null
+# Get IP of interface on private subnet to expose metrics
+TOKEN=\$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60" 2>/dev/null)
+
+if [ -n "\$TOKEN" ]; then
+ export PRIVATE_IP=\$(curl -H "X-aws-ec2-metadata-token: \$TOKEN" -s http://169.254.169.254/latest/meta-data/local-ipv4 2>/dev/null)
+else
+ echo "Could not get token to query for private IP"
+fi
+echo "Private IP \$PRIVATE_IP"
+
# Start the stack
echo "Starting the stack"
docker-compose -f temp/docker-compose.yml -p or up -d
diff --git a/docker-compose.yml b/docker-compose.yml
index 779b2e870..01ea58b8c 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -23,6 +23,8 @@ services:
- "${OR_SSL_PORT:-443}:443"
- "8883:8883"
- "127.0.0.1:8404:8404" # Localhost metrics access
+ - "${PRIVATE_IP:-127.0.0.1}:8404:8404" # Allows to also expose metrics on a given IP address,
+ # intended to be IP of the interface of the private subnet of the EC2 VM
volumes:
- proxy-data:/deployment
environment:
@@ -63,6 +65,8 @@ services:
condition: service_healthy
ports:
- "127.0.0.1:8405:8405" # Localhost metrics access
+ - "${PRIVATE_IP:-127.0.0.1}:8405:8405" # Allows to also expose metrics on a given IP address,
+ # intended to be IP of the interface of the private subnet of the EC2 VM
environment:
OR_SETUP_TYPE:
OR_ADMIN_PASSWORD:
diff --git a/profile/deploy.yml b/profile/deploy.yml
index ec3a62b93..6385fe8e1 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -112,6 +112,8 @@ services:
- "${OR_SSL_PORT:-443}:443" # HTTPS /auth directs to keycloak and other paths direct to manager
- "8883:8883" # MQTTS
- "127.0.0.1:8404:8404" # Localhost metrics access
+ - "${PRIVATE_IP:-127.0.0.1}:8404:8404" # Allows to also expose metrics on a given IP address,
+ # intended to be IP of the interface of the private subnet of the EC2 VM
# The OpenRemote Manager
manager:
@@ -137,6 +139,8 @@ services:
# - "8000:8000" # Remote debugging port - NOT FOR PRODUCTION USE!!!
# - "8085:8085" # JMX port - FOR DIAGNOSTICS ONLY!!!
# - "127.0.0.1:8405:8405" # Localhost metrics access
+ # - "${PRIVATE_IP:-127.0.0.1}:8405:8405" # Allows to also expose metrics on a given IP address,
+ # intended to be IP of the interface of the private subnet of the EC2 VM
logging:
options:
# Use very little logging for container STDOUT, this is