Adds openstack-exporter deployment script
Adds a bash script to deploy openstack-exporter, along with a Zuul job to test it. Change-Id: Id40aad02198747112e10d9457b350cee6f6d643e Signed-off-by: Leonie Chamberlin-Medd <leonie@stackhpc.com>
This commit is contained in:
committed by
Matt Crees
parent
8814b620e4
commit
38931e8544
30
.zuul.yaml
30
.zuul.yaml
@@ -5,10 +5,12 @@
|
||||
- watcher-prometheus-integration
|
||||
- devstack-prometheus
|
||||
- devstack-prometheus-custom-target
|
||||
- devstack-prometheus-openstack-exporter
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
- devstack-prometheus
|
||||
- devstack-prometheus-openstack-exporter
|
||||
|
||||
- job:
|
||||
name: devstack-prometheus-base
|
||||
@@ -28,6 +30,7 @@
|
||||
prometheus: true
|
||||
node_exporter: true
|
||||
podman_exporter: true
|
||||
openstack_exporter: false
|
||||
zuul_copy_output:
|
||||
/etc/prometheus/prometheus.yml: logs
|
||||
|
||||
@@ -52,6 +55,33 @@
|
||||
devstack_services:
|
||||
prometheus: true
|
||||
node_exporter: true
|
||||
openstack_exporter: false
|
||||
devstack_localrc:
|
||||
# custom target
|
||||
PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:9090,localhost:9100"
|
||||
|
||||
- job:
|
||||
#NOTE(mattcrees): Maintained for the CloudKitty project.
|
||||
# #cloudkitty on IRC.
|
||||
name: devstack-prometheus-openstack-exporter
|
||||
nodeset: openstack-single-node-noble
|
||||
parent: devstack
|
||||
description: |
|
||||
A DevStack job to install and configure prometheus, openstack services and
|
||||
openstack exporter service.
|
||||
required-projects:
|
||||
- opendev.org/openstack/devstack-plugin-prometheus
|
||||
- opendev.org/openstack/requirements
|
||||
vars:
|
||||
devstack_plugins:
|
||||
devstack-plugin-prometheus: https://opendev.org/openstack/devstack-plugin-prometheus
|
||||
devstack_services:
|
||||
prometheus: true
|
||||
node_exporter: false
|
||||
podman_exporter: false
|
||||
openstack_exporter: true
|
||||
zuul_copy_output:
|
||||
/etc/prometheus/prometheus.yml: logs
|
||||
devstack_localrc:
|
||||
# custom target
|
||||
PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:9090,localhost:9180"
|
||||
|
||||
@@ -7,5 +7,6 @@ scrape_configs:
|
||||
- targets: ["localhost:9882"]
|
||||
- targets: ["localhost:9090"] # prometheus target
|
||||
- targets: ["localhost:9100"] # node_exporter target
|
||||
- targets: ["localhost:9180"] # openstack-exporter target
|
||||
# labels:
|
||||
# fqdn: "controller" # node_exporter fqdn
|
||||
|
||||
86
devstack/lib/openstack_exporter
Normal file
86
devstack/lib/openstack_exporter
Normal file
@@ -0,0 +1,86 @@
|
||||
# lib/openstack_exporter
|
||||
# Functions to control the installation and configuration of openstack_exporter
|
||||
|
||||
# Save trace setting
|
||||
_XTRACE_OPENSTACK_EXPORTER=$(set +o | grep xtrace)
|
||||
set +o xtrace
|
||||
|
||||
OPENSTACK_EXPORTER_BINARY="/usr/local/bin/openstack_exporter"
|
||||
OPENSTACK_EXPORTER_SYSTEMD_SERVICE="devstack@openstack-exporter.service"
|
||||
OPENSTACK_EXPORTER_PORT=${OPENSTACK_EXPORTER_PORT:-9180}
|
||||
|
||||
function pre_install_openstack_exporter {
|
||||
# Install OS packages
|
||||
install_package wget tar
|
||||
}
|
||||
|
||||
function install_openstack_exporter {
|
||||
|
||||
local oe_tarball=openstack-exporter_${OPENSTACK_EXPORTER_VERSION}_linux_amd64.tar.gz
|
||||
local oe_url=https://github.com/openstack-exporter/openstack-exporter/releases/download/v${OPENSTACK_EXPORTER_VERSION}/${oe_tarball}
|
||||
|
||||
# Download openstack_exporter
|
||||
local oe_dest
|
||||
oe_dest=`get_extra_file ${oe_url}`
|
||||
|
||||
# Extract the tarball
|
||||
tar xzf ${oe_dest} -C $DEST
|
||||
|
||||
# Move binaries to /usr/local/bin
|
||||
sudo mv $DEST/openstack-exporter ${OPENSTACK_EXPORTER_BINARY}
|
||||
|
||||
# Set ownership
|
||||
sudo chown $(whoami):$(whoami) ${OPENSTACK_EXPORTER_BINARY}
|
||||
}
|
||||
|
||||
function init_openstack_exporter {
|
||||
export OS_COMPUTE_API_VERSION=2.87
|
||||
|
||||
|
||||
openstack_exporter_cmd=${OPENSTACK_EXPORTER_BINARY}
|
||||
openstack_exporter_cmd+=" --os-client-config /etc/openstack/clouds.yaml devstack-admin"
|
||||
|
||||
write_user_unit_file $OPENSTACK_EXPORTER_SYSTEMD_SERVICE "$openstack_exporter_cmd" "" "$STACK_USER" "OS_COMPUTE_API_VERSION=2.1"
|
||||
|
||||
enable_service $OPENSTACK_EXPORTER_SYSTEMD_SERVICE
|
||||
}
|
||||
|
||||
function start_openstack_exporter {
|
||||
start_service $OPENSTACK_EXPORTER_SYSTEMD_SERVICE
|
||||
}
|
||||
function stop_openstack_exporter {
|
||||
stop_service $OPENSTACK_EXPORTER_SYSTEMD_SERVICE
|
||||
}
|
||||
|
||||
function cleanup_openstack_exporter {
|
||||
stop_openstack_exporter
|
||||
disable_service $OPENSTACK_EXPORTER_SYSTEMD_SERVICE
|
||||
|
||||
# Remove systemd unit files
|
||||
local unitfile="$SYSTEMD_DIR/$OPENSTACK_EXPORTER_SYSTEMD_SERVICE"
|
||||
sudo rm -f $unitfile
|
||||
$SYSTEMCTL daemon-reload
|
||||
|
||||
# Remove OpenStack Exporter binaries
|
||||
sudo rm -rf $OPENSTACK_EXPORTER_BINARY
|
||||
|
||||
# Remove untar location
|
||||
sudo rm -rf $DEST/openstack-exporter
|
||||
}
|
||||
|
||||
function wait_for_data {
|
||||
# Adding sleep time so that metrics is pushed by openstack exporter
|
||||
sleep 60
|
||||
}
|
||||
|
||||
function check_data_openstack_exporter {
|
||||
if curl -s --head --request GET "http://$HOST_IP:$OPENSTACK_EXPORTER_PORT/metrics" | grep "200 OK" > /dev/null; then
|
||||
echo "#### Metrics data ####"
|
||||
curl "http://$HOST_IP:$OPENSTACK_EXPORTER_PORT/metrics"
|
||||
else
|
||||
die $LINENO "Couldn't get data from openstack_exporter"
|
||||
fi
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$_XTRACE_OPENSTACK_EXPORTER
|
||||
@@ -7,6 +7,7 @@ set -o xtrace
|
||||
echo_summary "devstack-plugin-prometheus's plugin.sh was called..."
|
||||
. $DEST/devstack-plugin-prometheus/devstack/lib/prometheus
|
||||
. $DEST/devstack-plugin-prometheus/devstack/lib/node_exporter
|
||||
. $DEST/devstack-plugin-prometheus/devstack/lib/openstack_exporter
|
||||
. $DEST/devstack-plugin-prometheus/devstack/lib/podman_exporter
|
||||
. $DEST/devstack-plugin-prometheus/devstack/lib/observabilityclient
|
||||
|
||||
@@ -107,6 +108,52 @@ if is_service_enabled node_exporter; then
|
||||
fi
|
||||
fi
|
||||
|
||||
## Openstack Exporter
|
||||
if is_service_enabled openstack_exporter; then
|
||||
if [[ "$1" == "source" ]]; then
|
||||
# Initial source of lib script
|
||||
source $(dirname "$0")/lib/openstack_exporter
|
||||
fi
|
||||
|
||||
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
|
||||
# Set up system services
|
||||
echo_summary "Configuring system services openstack exporter"
|
||||
pre_install_openstack_exporter
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "install" ]]; then
|
||||
# Perform installation of service source
|
||||
echo_summary "Installing openstack exporter"
|
||||
install_openstack_exporter
|
||||
|
||||
elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
|
||||
# Configure after the other layer 1 and 2 services have been configured
|
||||
echo_summary "Configuring openstack_exporter"
|
||||
init_openstack_exporter
|
||||
echo_summary "Starting openstack exporter service"
|
||||
start_openstack_exporter
|
||||
echo_summary "Give time to openstack_exporter to push metrics"
|
||||
wait_for_data
|
||||
check_data_openstack_exporter
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
# Shut down openstack exporter services
|
||||
# no-op
|
||||
echo_summary "Stopping openstack_exporter service"
|
||||
stop_openstack_exporter
|
||||
echo_summary "Cleaning openstack exporter service"
|
||||
cleanup_open_exporter
|
||||
fi
|
||||
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
# Remove state and transient data
|
||||
# Remember clean.sh first calls unstack.sh
|
||||
# no-op
|
||||
echo_summary "Cleaning openstack exporter service"
|
||||
cleanup_openstack_exporter
|
||||
fi
|
||||
fi
|
||||
|
||||
## Podman Exporter
|
||||
if is_service_enabled podman_exporter; then
|
||||
if [[ "$1" == "source" ]]; then
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# DevStack settings
|
||||
define_plugin prometheus node_exporter podman_exporter
|
||||
define_plugin prometheus node_exporter openstack_exporter podman_exporter
|
||||
enable_service prometheus
|
||||
enable_service node_exporter
|
||||
enable_service openstack_exporter
|
||||
|
||||
## Variables related to prometheus
|
||||
PROMETHEUS_VERSION=3.1.0
|
||||
@@ -18,6 +19,9 @@ NODE_EXPORTER_VERSION=1.8.2
|
||||
# List of "," excluded collector names
|
||||
NODE_EXPORTER_COLLECTOR_EXCLUDE=${NODE_EXPORTER_COLLECTOR_EXCLUDE:-""}
|
||||
|
||||
## Variables related to openstack exporter
|
||||
OPENSTACK_EXPORTER_VERSION=1.7.0
|
||||
|
||||
## Variables related to the observabilityclient
|
||||
GITREPO["python-observabilityclient"]=${OBSERVABILITYCLIENT_REPO:-${GIT_BASE}/openstack/python-observabilityclient.git}
|
||||
GITBRANCH["python-observabilityclient"]=${OBSERVABILITYCLIENT_BRANCH:-$TARGET_BRANCH}
|
||||
|
||||
Reference in New Issue
Block a user