Services demo - Installing and running
To install the services demo we're providing a self contained project you can download, unzip,
and run an installation script to quickly get started. Just follow these easy steps:
- Download and unzip the Prometheus Services Demo Installer.
- Run 'init.sh' file.
- Follow the instructions in the terminal output to start the services.
Services demo - Download and unzip
Once you have downloaded the project using the link provided previously, just unzip into its
own directory as shown (Note: examples shown are on Mac OSX system):
Services demo - Exploring the installer
Now change into the project directory explore the demo source code found in the install
directory as show. This is the code that the installer will build automatically:
Services demo - Run installation script
Time to build this project, so let's run the init script to build the services
project. Run the command below and see the next slide for the output and explanation:
Services demo - Installation introduction
The installation starts off with a nice ascii art sign to let you know you are about to install
the services project:
Services demo - Testing and building
Next the installer tests if you have GO installed and a valid version, if not you are pointed
to where to install it. In this example you see that it's a valid version of Go so it continues
on to build the services demo code:
Services demo - Completed building
If all goes well you have now see the following successful build message with pointers to how
to run the services demo binary you built and have the link to verify the metrics are exposed
in your browser:
Services demo - Testing the metrics
After starting the services binary as shown in the terminal output, it should have metrics
scraping end points available so that you can query them with PromQL. Test this at
Services demo - Prometheus configuration
While the metrics are exposed, they will not be scraped by Prometheus until you have updated its
configuration to add this new end point. Let's update our
file to add the services job as shown along with comments for clarity:
# Scraping Prometheus.
- job_name: "prometheus"
- targets: ["localhost:9090"]
# Scraping services demo.
- job_name: "services"
- targets: ["localhost:8080"]
Services demo - Applying the configuration
Previously you learned to restart the Prometheus to apply configuration changes. If you have
a running instance you don't want to lose a period of collecting time series data, so let's send
a restart signal instead using the
kill command. First we find the Prometheus server
process id (PID) using one command, then apply it using the command as shown below:
# Locate the Prometheus process id (PID).
$ ps aux | grep prometheus
erics 94110 1:31PM 0:05.28 ./prometheus --config.file=workshop-prometheus.yml
erics 97648 2:43PM 0:00.00 grep prometheus
# Send a restart signal to the PID we found.
$ kill -s HUP 94110
Intermezzo - Support helper configuration file
The previous Prometheus configuration changes were applied by you to your workshop file. In
case you want to return to this workshop at a later time, we provide a working adjusted
configuration file in the support directory, just start Prometheus as follows to start scraping
both Prometheus and the service demo endpoints:
$ ./prometheus --config.file=support/workshop-prometheus.yml
Services demo - Configuration applied
No matter which method you used to apply the new Prometheus configuration, validate it by
checking the log output, you should see something like this (example of using a signal to
Services demo - Validating setup
The last check to make sure it's working, execute
in the Prometheus console to generate a graph output something like the following (note, this has
been running awhile, hence the full graph):
Lab completed - Results
Next up, exploring basic queries...
Contact - are there any questions?