├── .gitignore ├── Infrastructure & System Monitoring using Prometheus.pdf ├── LICENSE ├── README.md ├── build-docker-images.sh ├── docker-images └── spring-boot-prometheus-demo │ ├── build.gradle │ ├── build.sh │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ └── main │ ├── docker │ ├── Dockerfile │ └── app │ │ └── docker-entrypoint.sh │ ├── java │ └── springboot │ │ └── prometheus │ │ └── DemoApplication.java │ └── resources │ └── application.properties └── steps ├── 1-run-prometheus-native └── prometheus-2.2.1.darwin-amd64 │ ├── LICENSE │ ├── NOTICE │ ├── console_libraries │ ├── menu.lib │ └── prom.lib │ ├── consoles │ ├── index.html.example │ ├── node-cpu.html │ ├── node-disk.html │ ├── node-overview.html │ ├── node.html │ ├── prometheus-overview.html │ └── prometheus.html │ ├── data │ └── wal │ │ └── .gitignore │ ├── prometheus │ ├── prometheus.yml │ └── promtool ├── 2-run-prometheus-using-docker ├── docker-compose.yml └── prometheus.yml ├── 3-add-host-metrics ├── docker-compose.yml └── prometheus.yml ├── 4-grafana ├── docker-compose.yml ├── node-exporter-single-server_rev7.json └── prometheus.yml ├── 5-monitor-docker-containers ├── docker-compose.yml ├── docker-dashboard_rev5.json └── prometheus.yml ├── 6-alerting ├── alert.rules ├── config.yml ├── docker-compose.yml ├── mailslurper-config.json └── prometheus.yml ├── 7-adding-application-metrics ├── docker-compose.yml └── prometheus.yml └── 8-consul-integration ├── docker-compose.yml ├── prometheus.yml ├── register-service1.json ├── register-service2.json └── register-services-with-consul.sh /.gitignore: -------------------------------------------------------------------------------- 1 | steps/1-run-prometheus-native/prometheus-1.5.2.darwin-amd64/data 2 | build/ 3 | .idea 4 | .gradle 5 | .classpath 6 | .project 7 | .settings 8 | **/data 9 | -------------------------------------------------------------------------------- /Infrastructure & System Monitoring using Prometheus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpas/infrastructure-and-system-monitoring-using-prometheus/5e8024b34a5d6e9282ffec6c2e7c4265fd36cf57/Infrastructure & System Monitoring using Prometheus.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Marco Pas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # General 2 | 3 | ## Prerequisites 4 | 5 | * Docker installed 6 | * Docker Compose installed 7 | * HTTPie installed - 8 | 9 | ### Build the required Docker images 10 | 11 | * Execute `./build-docker-images.sh` 12 | 13 | This will build the following images: 14 | 15 | * **Spring Boot Prometheus Demo**: Spring Boot app with custom metrics added 16 | 17 | ### Configuration 18 | 19 | * Please add your own Slack API webhook in `./steps/6-alerting/config.yml` 20 | 21 | --- 22 | 23 | ## Step 1: Running Prometheus native 24 | 25 | * Explain that Prometheus is a Go application which can just be extracted and run 26 | * Start Prometheus via commandline ./prometheus and show that is running 27 | * Prometheus 28 | * Navigate to > show the metrics that Prometheus itself is generating 29 | * Navigate to > show prometheus webinterface 30 | * Show Config file (prometheus.yml) -> show Targets 31 | * Explain that scraping can be done by various ways (Consul, DNS, or dropping in new config file) 32 | 33 | ## Step 2: Run Prometheus using Docker 34 | 35 | * Start Prometheus using docker-compose > dc up 36 | * Show docker-compose.yml > including portmapping 37 | 38 | ## Step 3: Add host metrics 39 | 40 | * Start Prometheus using docker-compose > dc up 41 | * Node exporter 42 | * Explain Node Exporter 43 | * Show Node Exporter config inside prometheus.yml > explain scraping 44 | * Navigate to 45 | * Explain metrics 46 | * Prometheus 47 | * Navigate to http://localhost:9090 48 | * Show to to query for metrics using the autocomplete 49 | * Show how to play using the query language (console & graph) 50 | * `node_network_receive_bytes` 51 | * `node_network_receive_bytes{device="eth0"}` 52 | * `node_network_receive_bytes{device="eth0"}[5m]` 53 | * `rate(node_network_receive_bytes{device="eth0"}[5m])` 54 | 55 | ## Step 4: Grafana 56 | 57 | * Start Prometheus using docker-compose > dc up 58 | * Grafana 59 | * Explain Grafana 60 | * Navigate to http://localhost:3000 61 | * Login using > admin/admin 62 | * Add Datasource 63 | * Create new Dashboard with widget containing graph from memory 64 | * `node_network_receive_bytes` 65 | * `node_network_receive_bytes{device="eth0"}` 66 | * Import dashboard to show the graphs coming from default monitoring of Prometheus 67 | * Import single server dashboard 68 | 69 | ## Step 5: Monitor Docker Containers 70 | 71 | * Start Prometheus using docker-compose > dc up 72 | * cAdvisor 73 | * Explain cAdvisor 74 | * Navigate to http://localhost:8093 75 | * Show gauges and meters 76 | * Navigate to http://localhost:8093/metrics 77 | * Show metrics 78 | * Grafana 79 | * Navigate to http://localhost:3000 80 | * Login using > admin/admin 81 | * Add Datasource 82 | * Import cAdvisor Dashboard 83 | 84 | ## Step 6: Alerting 85 | 86 | * Start Prometheus using docker-compose > dc up 87 | * Show alert.rules 88 | * Show alert-manager.yml 89 | * Alert Manager 90 | * Explain the Alert Manager 91 | * Show alerts http://localhost:9093 92 | * Prometheus 93 | * Show alerts in http://localhost:9090 94 | * Introduce the Ping container 95 | * Stop/Start the Ping container -> `docker-compose stop ping` 96 | * View the results in: 97 | * Slack 98 | * Mailslurper: http://localhost:9000 99 | 100 | ## Step 7: Instrumenting applications 101 | 102 | * Start Prometheus using docker-compose > dc up 103 | * SpringBoot App 104 | * Navigate to http://localhost:8081/metrics 105 | * Explain that these are the wrong metrics (Spring Boot Actuator) 106 | * Navigate to http://localhost:8081/prometheus 107 | * Show the ‘helloworld_requests_total’ counter being 0 108 | * Navigate to http://localhost:8081/helloworld 109 | * This increases the counter with 1 110 | * Navigate to http://localhost:8081/prometheus 111 | * Show the ‘helloworld_requests_total’ counter being incremented 112 | * Prometheus 113 | * Show ‘prometheus.yml’ > explain custom metrics path 114 | * Navigate to http://localhost:9090 115 | * Show the metric ‘helloworld_requests_total’ in the web ui 116 | 117 | 118 | ## Step 8: Consul demo 119 | 120 | * Start Prometheus using docker-compose > dc up 121 | * Prometheus 122 | * Show prometheus.yml > explain consul config 123 | * Navigate to http://localhost:9090 124 | * Show targets and see that we are missing the services 125 | * Consul 126 | * Navigate to http://localhost:8500 127 | * Show missing services 128 | * Register the services using ‘register-services-with-consul.sh` 129 | * Show the services appearing in Consul 130 | * Prometheus 131 | * Navigate to http://localhost:9090 132 | * Show targets and see that the services have appeared 133 | 134 | --- 135 | 136 | # Demo Links 137 | 138 | * [Prometheus webinterface][prometheus-ui] 139 | * [Prometheus metrics][prometheus-metrics] 140 | * [Node Exporter][node-exporter] 141 | * [Node Exporter metrics][node-exporter-metrics] 142 | * [AlertManager][alertmanager] 143 | * [cAdvisor webinterface][cadvisor-ui] 144 | * [cAdvisor metrics][cadvisor-metrics] 145 | * [Grafana][grafana] 146 | * [Mailslurper][mailslurper] 147 | * [SpringBoot Demo App * metrics][springboot metrics] 148 | * [SpringBoot Demo App * helloworld][springboot helloworld] 149 | 150 | [prometheus-ui]: http://localhost:9090 151 | [prometheus-metrics]: http://localhost:9090/metrics 152 | [node-exporter]: http://localhost:9100 153 | [node-exporter-metrics]: http://localhost:9100/metrics 154 | [alertmanager]: http://localhost:9093 155 | [cadvisor-ui]: http://localhost:8095 156 | [cadvisor-metrics]: http://localhost:8095/metrics 157 | [grafana]: http://localhost:3000 158 | [alert-manager]: http://localhost:9093 159 | [mailslurper]: http://localhost:9000 160 | [springboot metrics]: http://localhost:8080/metrics 161 | [springboot helloworld]: http://localhost:8080/helloworld 162 | 163 | References: 164 | https://github.com/stefanprodan/dockprom 165 | -------------------------------------------------------------------------------- /build-docker-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "" 3 | echo "Building Spring Boot Prometheus Demo image" 4 | echo "--------------------------------------------------------------------------------" 5 | cd ./docker-images/spring-boot-prometheus-demo 6 | bash build.sh 7 | -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext { 3 | springBootVersion = '1.5.3.RELEASE' 4 | } 5 | repositories { 6 | mavenCentral() 7 | } 8 | dependencies { 9 | classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 10 | } 11 | } 12 | 13 | apply plugin: 'java' 14 | apply plugin: 'eclipse' 15 | apply plugin: 'org.springframework.boot' 16 | 17 | version = '0.0.1-SNAPSHOT' 18 | sourceCompatibility = 1.8 19 | 20 | repositories { 21 | mavenCentral() 22 | } 23 | 24 | 25 | dependencies { 26 | compile('org.springframework.boot:spring-boot-starter-web') 27 | testCompile('org.springframework.boot:spring-boot-starter-test') 28 | 29 | compile('io.prometheus:simpleclient_spring_boot:0.0.21') 30 | } 31 | 32 | String dockerImageName = "spring-boot-prometheus-demo" 33 | 34 | task buildDockerImage(type:Exec) { 35 | group = 'docker' 36 | description = 'Build a docker image' 37 | commandLine 'docker', 'build', '-f', 'build/docker/Dockerfile', '-t', "${dockerImageName}", 'build/docker' 38 | 39 | doFirst { 40 | println ">> Creating image: ${dockerImageName}" 41 | copy { 42 | from 'src/main/docker/app/' 43 | into 'build/docker/app' 44 | } 45 | copy { 46 | from jar.archivePath 47 | into 'build/docker/app/' 48 | } 49 | copy { 50 | from('src/main/docker/') { 51 | include 'Dockerfile' 52 | } 53 | into 'build/docker' 54 | } 55 | file("build/docker/app/${jar.archiveName}").renameTo("build/docker/app/application.jar") 56 | } 57 | } -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ./gradlew clean bootRepackage buildDockerImage -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpas/infrastructure-and-system-monitoring-using-prometheus/5e8024b34a5d6e9282ffec6c2e7c4265fd36cf57/docker-images/spring-boot-prometheus-demo/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip 6 | -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save ( ) { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8u66-jdk 2 | 3 | ## Publish the 8080 port 4 | EXPOSE 8080 5 | 6 | # Create app that holds the application.jar file 7 | RUN mkdir -p /app 8 | WORKDIR /app 9 | 10 | COPY /app/application.jar application.jar 11 | COPY /app/docker-entrypoint.sh docker-entrypoint.sh 12 | 13 | # Set file permissions 14 | RUN chmod +x docker-entrypoint.sh 15 | 16 | # Set start script as default command 17 | CMD ["./docker-entrypoint.sh"] -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/src/main/docker/app/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | exec java ${JAVA_OPTS} -jar application.jar $@ -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/src/main/java/springboot/prometheus/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package springboot.prometheus; 2 | 3 | import io.prometheus.client.Counter; 4 | import io.prometheus.client.spring.boot.EnablePrometheusEndpoint; 5 | import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | @EnablePrometheusEndpoint 12 | @EnableSpringBootMetricsCollector 13 | @RestController 14 | @SpringBootApplication 15 | public class DemoApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(DemoApplication.class, args); 19 | } 20 | 21 | static final Counter requests = Counter.build().name("helloworld_requests_total").help("HelloWorld Total requests.").register(); 22 | 23 | @RequestMapping("/helloworld") 24 | String home() { 25 | requests.inc(); 26 | return "Hello World!"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /docker-images/spring-boot-prometheus-demo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.security.enabled=false -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/NOTICE: -------------------------------------------------------------------------------- 1 | The Prometheus systems and service monitoring server 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | 7 | 8 | The following components are included in this product: 9 | 10 | Bootstrap 11 | http://getbootstrap.com 12 | Copyright 2011-2014 Twitter, Inc. 13 | Licensed under the MIT License 14 | 15 | bootstrap3-typeahead.js 16 | https://github.com/bassjobsen/Bootstrap-3-Typeahead 17 | Original written by @mdo and @fat 18 | Copyright 2014 Bass Jobsen @bassjobsen 19 | Licensed under the Apache License, Version 2.0 20 | 21 | fuzzy 22 | https://github.com/mattyork/fuzzy 23 | Original written by @mattyork 24 | Copyright 2012 Matt York 25 | Licensed under the MIT License 26 | 27 | bootstrap-datetimepicker.js 28 | https://github.com/Eonasdan/bootstrap-datetimepicker 29 | Copyright 2015 Jonathan Peterson (@Eonasdan) 30 | Licensed under the MIT License 31 | 32 | moment.js 33 | https://github.com/moment/moment/ 34 | Copyright JS Foundation and other contributors 35 | Licensed under the MIT License 36 | 37 | Rickshaw 38 | https://github.com/shutterstock/rickshaw 39 | Copyright 2011-2014 by Shutterstock Images, LLC 40 | See https://github.com/shutterstock/rickshaw/blob/master/LICENSE for license details 41 | 42 | mustache.js 43 | https://github.com/janl/mustache.js 44 | Copyright 2009 Chris Wanstrath (Ruby) 45 | Copyright 2010-2014 Jan Lehnardt (JavaScript) 46 | Copyright 2010-2015 The mustache.js community 47 | Licensed under the MIT License 48 | 49 | jQuery 50 | https://jquery.org 51 | Copyright jQuery Foundation and other contributors 52 | Licensed under the MIT License 53 | 54 | Protocol Buffers for Go with Gadgets 55 | http://github.com/gogo/protobuf/ 56 | Copyright (c) 2013, The GoGo Authors. 57 | See source code for license details. 58 | 59 | Go support for leveled logs, analogous to 60 | https://code.google.com/p/google-glog/ 61 | Copyright 2013 Google Inc. 62 | Licensed under the Apache License, Version 2.0 63 | 64 | Support for streaming Protocol Buffer messages for the Go language (golang). 65 | https://github.com/matttproud/golang_protobuf_extensions 66 | Copyright 2013 Matt T. Proud 67 | Licensed under the Apache License, Version 2.0 68 | 69 | DNS library in Go 70 | http://miek.nl/posts/2014/Aug/16/go-dns-package/ 71 | Copyright 2009 The Go Authors, 2011 Miek Gieben 72 | See https://github.com/miekg/dns/blob/master/LICENSE for license details. 73 | 74 | LevelDB key/value database in Go 75 | https://github.com/syndtr/goleveldb 76 | Copyright 2012 Suryandaru Triandana 77 | See https://github.com/syndtr/goleveldb/blob/master/LICENSE for license details. 78 | 79 | gosnappy - a fork of code.google.com/p/snappy-go 80 | https://github.com/syndtr/gosnappy 81 | Copyright 2011 The Snappy-Go Authors 82 | See https://github.com/syndtr/gosnappy/blob/master/LICENSE for license details. 83 | 84 | go-zookeeper - Native ZooKeeper client for Go 85 | https://github.com/samuel/go-zookeeper 86 | Copyright (c) 2013, Samuel Stauffer 87 | See https://github.com/samuel/go-zookeeper/blob/master/LICENSE for license details. 88 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/console_libraries/menu.lib: -------------------------------------------------------------------------------- 1 | {{/* vim: set ft=html: */}} 2 | 3 | {{/* Navbar, should be passed . */}} 4 | {{ define "navbar" }} 5 | 26 | {{ end }} 27 | 28 | {{/* LHS menu, should be passed . */}} 29 | {{ define "menu" }} 30 |
31 |
    32 | {{ template "_menuItem" (args . "index.html.example" "Overview") }} 33 | 34 | {{ if query "up{job='node'}" }} 35 | {{ template "_menuItem" (args . "node.html" "Node") }} 36 | {{ if match "^node" .Path }} 37 | {{ if .Params.instance }} 38 | 51 | {{ end }} 52 | {{ end }} 53 | {{ end }} 54 | 55 | {{ if query "up{job='prometheus'}" }} 56 | {{ template "_menuItem" (args . "prometheus.html" "Prometheus") }} 57 | {{ if match "^prometheus" .Path }} 58 | {{ if .Params.instance }} 59 | 64 | {{ end }} 65 | {{ end }} 66 | {{ end }} 67 | 68 |
69 |
70 | {{ end }} 71 | 72 | {{/* Helper, pass (args . path name) */}} 73 | {{ define "_menuItem" }} 74 |
  • {{ .arg2 }}
  • 75 | {{ end }} 76 | 77 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/console_libraries/prom.lib: -------------------------------------------------------------------------------- 1 | {{/* vim: set ft=html: */}} 2 | {{/* Load Prometheus console library JS/CSS. Should go in */}} 3 | {{ define "prom_console_head" }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | {{ end }} 18 | 19 | {{/* Top of all pages. */}} 20 | {{ define "head" }} 21 | 22 | 23 | {{ template "prom_console_head" }} 24 | 25 | 26 | {{ template "navbar" . }} 27 | {{ template "menu" . }} 28 | {{ end }} 29 | 30 | {{ define "__prom_query_drilldown_noop" }}{{ . }}{{ end }} 31 | {{ define "humanize" }}{{ humanize . }}{{ end }} 32 | {{ define "humanizeNoSmallPrefix" }}{{ if and (lt . 1.0) (gt . -1.0) }}{{ printf "%.3g" . }}{{ else }}{{ humanize . }}{{ end }}{{ end }} 33 | {{ define "humanize1024" }}{{ humanize1024 . }}{{ end }} 34 | {{ define "humanizeDuration" }}{{ humanizeDuration . }}{{ end }} 35 | {{ define "humanizeTimestamp" }}{{ humanizeTimestamp . }}{{ end }} 36 | {{ define "printf.1f" }}{{ printf "%.1f" . }}{{ end }} 37 | {{ define "printf.3g" }}{{ printf "%.3g" . }}{{ end }} 38 | 39 | {{/* prom_query_drilldown (args expr suffix? renderTemplate?) 40 | Displays the result of the expression, with a link to /graph for it. 41 | 42 | renderTemplate is the name of the template to use to render the value. 43 | */}} 44 | {{ define "prom_query_drilldown" }} 45 | {{ $expr := .arg0 }}{{ $suffix := (or .arg1 "") }}{{ $renderTemplate := (or .arg2 "__prom_query_drilldown_noop") }} 46 | {{ with query $expr }}{{tmpl $renderTemplate ( . | first | value )}}{{ $suffix }}{{ else }}-{{ end }} 47 | {{ end }} 48 | 49 | {{ define "prom_path" }}/consoles/{{ .Path }}?{{ range $param, $value := .Params }}{{ $param }}={{ $value }}&{{ end }}{{ end }}" 50 | 51 | {{ define "prom_right_table_head" }} 52 |
    53 | 54 | {{ end }} 55 | {{ define "prom_right_table_tail" }} 56 |
    57 |
    58 | {{ end }} 59 | 60 | {{/* RHS table head, pass job name. Should be used after prom_right_table_head. */}} 61 | {{ define "prom_right_table_job_head" }} 62 | 63 | {{ . }} 64 | {{ template "prom_query_drilldown" (args (printf "sum(up{job='%s'})" .)) }} / {{ template "prom_query_drilldown" (args (printf "count(up{job='%s'})" .)) }} 65 | 66 | 67 | CPU 68 | {{ template "prom_query_drilldown" (args (printf "avg by(job)(irate(process_cpu_seconds_total{job='%s'}[5m]))" .) "s/s" "humanizeNoSmallPrefix") }} 69 | 70 | 71 | Memory 72 | {{ template "prom_query_drilldown" (args (printf "avg by(job)(process_resident_memory_bytes{job='%s'})" .) "B" "humanize1024") }} 73 | 74 | {{ end }} 75 | 76 | 77 | {{ define "prom_content_head" }} 78 |
    79 |
    80 | {{ template "prom_graph_timecontrol" . }} 81 | {{ end }} 82 | {{ define "prom_content_tail" }} 83 |
    84 |
    85 | {{ end }} 86 | 87 | {{ define "prom_graph_timecontrol" }} 88 |
    89 |
    90 |
    91 | 94 | 95 | 98 |
    99 | 100 |
    101 | 104 | 105 | 108 |
    109 | 110 |
    111 |
    112 | 117 | 120 | 122 |
    123 |
    124 |
    125 | 128 |
    129 | {{ end }} 130 | 131 | {{/* Bottom of all pages. */}} 132 | {{ define "tail" }} 133 | 134 | 135 | {{ end }} 136 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/index.html.example: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_right_table_head" }} 4 | {{ template "prom_right_table_tail" }} 5 | 6 | {{ template "prom_content_head" . }} 7 |

    Overview

    8 |

    These are example consoles for Prometheus.

    9 | 10 |

    These consoles expect exporters to have the following job labels:

    11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
    ExporterJob label
    Node Exporternode
    Prometheusprometheus
    25 | 26 | {{ template "prom_content_tail" . }} 27 | 28 | {{ template "tail" }} 29 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/node-cpu.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_right_table_head" }} 4 | 5 | CPU(s): {{ template "prom_query_drilldown" (args (printf "scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance)) }} 6 | 7 | {{ range printf "sum by (mode)(irate(node_cpu{job='node',instance='%s'}[5m])) * 100 / scalar(count(count by (cpu)(node_cpu{job='node',instance='%s'})))" .Params.instance .Params.instance | query | sortByLabel "mode" }} 8 | 9 | {{ .Labels.mode | title }} CPU 10 | {{ .Value | printf "%.1f" }}% 11 | 12 | {{ end }} 13 | Misc 14 | 15 | Processes Running 16 | {{ template "prom_query_drilldown" (args (printf "node_procs_running{job='node',instance='%s'}" .Params.instance) "" "humanize") }} 17 | 18 | 19 | Processes Blocked 20 | {{ template "prom_query_drilldown" (args (printf "node_procs_blocked{job='node',instance='%s'}" .Params.instance) "" "humanize") }} 21 | 22 | 23 | Forks 24 | {{ template "prom_query_drilldown" (args (printf "irate(node_forks{job='node',instance='%s'}[5m])" .Params.instance) "/s" "humanize") }} 25 | 26 | 27 | Context Switches 28 | {{ template "prom_query_drilldown" (args (printf "irate(node_context_switches{job='node',instance='%s'}[5m])" .Params.instance) "/s" "humanize") }} 29 | 30 | 31 | Interrupts 32 | {{ template "prom_query_drilldown" (args (printf "irate(node_intr{job='node',instance='%s'}[5m])" .Params.instance) "/s" "humanize") }} 33 | 34 | 35 | 1m Loadavg 36 | {{ template "prom_query_drilldown" (args (printf "node_load1{job='node',instance='%s'}" .Params.instance)) }} 37 | 38 | 39 | 40 | {{ template "prom_right_table_tail" }} 41 | 42 | {{ template "prom_content_head" . }} 43 |

    Node CPU - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}

    44 | 45 |

    CPU Usage

    46 |
    47 | 58 | {{ template "prom_content_tail" . }} 59 | 60 | {{ template "tail" }} 61 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/node-disk.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_content_head" . }} 4 |

    Node Disk - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}

    5 | 6 |

    Disk I/O Utilization

    7 |
    8 | 22 |

    Filesystem Usage

    23 |
    24 | 37 | 38 | {{ template "prom_right_table_head" }} 39 | Disks 40 | 41 | {{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device" }} 42 | {{ .Labels.device }} 43 | 44 | Utilization 45 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.1f") }} 46 | 47 | 48 | Throughput 49 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_sectors_read{job='node',instance='%s',device='%s'}[5m]) * 512 + irate(node_disk_sectors_written{job='node',instance='%s',device='%s'}[5m]) * 512" .Labels.instance .Labels.device .Labels.instance .Labels.device) "B/s" "humanize") }} 50 | 51 | 52 | Avg Read Time 53 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_read_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 / irate(node_disk_reads_completed{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device .Labels.instance .Labels.device) "s" "humanize") }} 54 | 55 | 56 | Avg Write Time 57 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_write_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 / irate(node_disk_writes_completed{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device .Labels.instance .Labels.device) "s" "humanize") }} 58 | 59 | {{ end }} 60 | Filesystem Fullness 61 | 62 | {{ define "roughlyNearZero" }} 63 | {{ if gt .1 . }}~0{{ else }}{{ printf "%.1f" . }}{{ end }} 64 | {{ end }} 65 | {{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "mountpoint" }} 66 | 67 | {{ .Labels.mountpoint }} 68 | {{ template "prom_query_drilldown" (args (printf "100 - node_filesystem_free{job='node',instance='%s',mountpoint='%s'} / node_filesystem_size{job='node'} * 100" .Labels.instance .Labels.mountpoint) "%" "roughlyNearZero") }} 69 | 70 | {{ end }} 71 | 72 | 73 | {{ template "prom_right_table_tail" }} 74 | 75 | {{ template "prom_content_tail" . }} 76 | 77 | {{ template "tail" }} 78 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/node-overview.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_content_head" . }} 4 |

    Node Overview - {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Params.instance }}

    5 | 6 |

    CPU Usage

    7 |
    8 | 19 | 20 |

    Disk I/O Utilization

    21 |
    22 | 36 | 37 |

    Memory

    38 |
    39 | 57 | 58 | {{ template "prom_right_table_head" }} 59 | Overview 60 | 61 | User CPU 62 | {{ template "prom_query_drilldown" (args (printf "sum(irate(node_cpu{job='node',instance='%s',mode='user'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }} 63 | 64 | 65 | System CPU 66 | {{ template "prom_query_drilldown" (args (printf "sum(irate(node_cpu{job='node',instance='%s',mode='system'}[5m])) * 100 / count(count by (cpu)(node_cpu{job='node',instance='%s'}))" .Params.instance .Params.instance) "%" "printf.1f") }} 67 | 68 | 69 | Memory Total 70 | {{ template "prom_query_drilldown" (args (printf "node_memory_MemTotal{job='node',instance='%s'}" .Params.instance) "B" "humanize1024") }} 71 | 72 | 73 | Memory Free 74 | {{ template "prom_query_drilldown" (args (printf "node_memory_MemFree{job='node',instance='%s'}" .Params.instance) "B" "humanize1024") }} 75 | 76 | 77 | Network 78 | 79 | {{ range printf "node_network_receive_bytes{job='node',instance='%s',device!='lo'}" .Params.instance | query | sortByLabel "device" }} 80 | 81 | {{ .Labels.device }} Received 82 | {{ template "prom_query_drilldown" (args (printf "irate(node_network_receive_bytes{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device) "B/s" "humanize") }} 83 | 84 | 85 | {{ .Labels.device }} Transmitted 86 | {{ template "prom_query_drilldown" (args (printf "irate(node_network_transmit_bytes{job='node',instance='%s',device='%s'}[5m])" .Labels.instance .Labels.device) "B/s" "humanize") }} 87 | 88 | {{ end }} 89 | 90 | 91 | Disks 92 | 93 | {{ range printf "node_disk_io_time_ms{job='node',instance='%s',device!~'^(md\\\\d+$|dm-)'}" .Params.instance | query | sortByLabel "device" }} 94 | 95 | {{ .Labels.device }} Utilization 96 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_io_time_ms{job='node',instance='%s',device='%s'}[5m]) / 1000 * 100" .Labels.instance .Labels.device) "%" "printf.1f") }} 97 | 98 | {{ end }} 99 | {{ range printf "node_disk_io_time_ms{job='node',instance='%s'}" .Params.instance | query | sortByLabel "device" }} 100 | 101 | {{ .Labels.device }} Throughput 102 | {{ template "prom_query_drilldown" (args (printf "irate(node_disk_sectors_read{job='node',instance='%s',device='%s'}[5m]) * 512 + irate(node_disk_sectors_written{job='node',instance='%s',device='%s'}[5m]) * 512" .Labels.instance .Labels.device .Labels.instance .Labels.device) "B/s" "humanize") }} 103 | 104 | {{ end }} 105 | 106 | Filesystem Fullness 107 | 108 | {{ define "roughlyNearZero" }} 109 | {{ if gt .1 . }}~0{{ else }}{{ printf "%.1f" . }}{{ end }} 110 | {{ end }} 111 | {{ range printf "node_filesystem_size{job='node',instance='%s'}" .Params.instance | query | sortByLabel "mountpoint" }} 112 | 113 | {{ .Labels.mountpoint }} 114 | {{ template "prom_query_drilldown" (args (printf "100 - node_filesystem_free{job='node',instance='%s',mountpoint='%s'} / node_filesystem_size{job='node'} * 100" .Labels.instance .Labels.mountpoint) "%" "roughlyNearZero") }} 115 | 116 | {{ end }} 117 | 118 | {{ template "prom_right_table_tail" }} 119 | 120 | {{ template "prom_content_tail" . }} 121 | 122 | {{ template "tail" }} 123 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/node.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_right_table_head" }} 4 | 5 | Node 6 | {{ template "prom_query_drilldown" (args "sum(up{job='node'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='node'})") }} 7 | 8 | {{ template "prom_right_table_tail" }} 9 | 10 | {{ template "prom_content_head" . }} 11 |

    Node

    12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {{ range query "up{job='node'}" | sortByLabel "instance" }} 21 | 22 | 23 | Yes{{ else }} class="alert-danger">No{{ end }} 24 | 25 | 26 | 27 | {{ else }} 28 | 29 | {{ end }} 30 | 31 | 32 | {{ template "prom_content_tail" . }} 33 | 34 | {{ template "tail" }} 35 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/prometheus-overview.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_right_table_head" }} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | {{ range printf "http_request_duration_microseconds_count{job='prometheus',instance='%s',handler=~'^(query.*|federate|consoles)$'}" .Params.instance | query | sortByLabel "handler" }} 54 | 55 | 56 | 57 | 58 | {{ end }} 59 | 60 | {{ template "prom_right_table_tail" }} 61 | 62 | {{ template "prom_content_head" . }} 63 |

    Prometheus Overview - {{ .Params.instance }}

    64 | 65 |

    Ingested Samples

    66 |
    67 | 78 | 79 |

    HTTP Server

    80 |
    81 | 92 | 93 | {{ template "prom_content_tail" . }} 94 | 95 | {{ template "tail" }} 96 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/consoles/prometheus.html: -------------------------------------------------------------------------------- 1 | {{ template "head" . }} 2 | 3 | {{ template "prom_right_table_head" }} 4 | 5 | 6 | 7 | 8 | {{ template "prom_right_table_tail" }} 9 | 10 | {{ template "prom_content_head" . }} 11 |

    Prometheus

    12 | 13 |
    NodeUpCPU
    Used
    Memory
    Available
    {{ reReplaceAll "(.*?://)([^:/]+?)(:\\d+)?/.*" "$2" .Labels.instance }}{{ template "prom_query_drilldown" (args (printf "100 * (1 - avg by(instance)(irate(node_cpu{job='node',mode='idle',instance='%s'}[5m])))" .Labels.instance) "%" "printf.1f") }}{{ template "prom_query_drilldown" (args (printf "node_memory_MemFree{job='node',instance='%s'} + node_memory_Cached{job='node',instance='%s'} + node_memory_Buffers{job='node',instance='%s'}" .Labels.instance .Labels.instance .Labels.instance) "B" "humanize1024") }}
    No nodes found.
    Overview
    CPU{{ template "prom_query_drilldown" (args (printf "irate(process_cpu_seconds_total{job='prometheus',instance='%s'}[5m])" .Params.instance) "s/s" "humanizeNoSmallPrefix") }}
    Memory{{ template "prom_query_drilldown" (args (printf "process_resident_memory_bytes{job='prometheus',instance='%s'}" .Params.instance) "B" "humanize1024") }}
    Version{{ with query (printf "prometheus_build_info{job='prometheus',instance='%s'}" .Params.instance) }}{{. | first | label "version"}}{{end}}
    Storage
    Ingested Samples{{ template "prom_query_drilldown" (args (printf "irate(prometheus_tsdb_head_samples_appended_total{job='prometheus',instance='%s'}[5m])" .Params.instance) "/s" "humanizeNoSmallPrefix") }}
    Head Series{{ template "prom_query_drilldown" (args (printf "prometheus_tsdb_head_series{job='prometheus',instance='%s'}" .Params.instance) "" "humanize") }}
    Blocks Loaded{{ template "prom_query_drilldown" (args (printf "prometheus_tsdb_blocks_loaded{job='prometheus',instance='%s'}" .Params.instance) "" "humanize") }}
    Rules
    Evaluation Duration{{ template "prom_query_drilldown" (args (printf "irate(prometheus_evaluator_duration_seconds_sum{job='prometheus',instance='%s'}[5m]) / irate(prometheus_evaluator_duration_seconds_count{job='prometheus',instance='%s'}[5m])" .Params.instance .Params.instance) "" "humanizeDuration") }}
    Notification Latency{{ template "prom_query_drilldown" (args (printf "irate(prometheus_notifications_latency_seconds_sum{job='prometheus',instance='%s'}[5m]) / irate(prometheus_notifications_latency_seconds_count{job='prometheus',instance='%s'}[5m])" .Params.instance .Params.instance) "" "humanizeDuration") }}
    Notification Queue{{ template "prom_query_drilldown" (args (printf "prometheus_notifications_queue_length{job='prometheus',instance='%s'}" .Params.instance) "" "humanize") }}
    HTTP Server
    {{ .Labels.handler }}{{ template "prom_query_drilldown" (args (printf "irate(http_request_duration_microseconds_count{job='prometheus',instance='%s',handler='%s'}[5m])" .Labels.instance .Labels.handler) "/s" "humanizeNoSmallPrefix") }}
    Prometheus{{ template "prom_query_drilldown" (args "sum(up{job='prometheus'})") }} / {{ template "prom_query_drilldown" (args "count(up{job='prometheus'})") }}
    14 | 15 | 16 | 17 | 18 | 19 | 20 | {{ range query "up{job='prometheus'}" | sortByLabel "instance" }} 21 | 22 | 23 | 24 | 25 | 26 | 27 | {{ else }} 28 | 29 | {{ end }} 30 | 31 | {{ template "prom_content_tail" . }} 32 | 33 | {{ template "tail" }} 34 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/data/wal/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/prometheus: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpas/infrastructure-and-system-monitoring-using-prometheus/5e8024b34a5d6e9282ffec6c2e7c4265fd36cf57/steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/prometheus -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Alertmanager configuration 8 | alerting: 9 | alertmanagers: 10 | - static_configs: 11 | - targets: 12 | # - alertmanager:9093 13 | 14 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 15 | rule_files: 16 | # - "first_rules.yml" 17 | # - "second_rules.yml" 18 | 19 | # A scrape configuration containing exactly one endpoint to scrape: 20 | # Here it's Prometheus itself. 21 | scrape_configs: 22 | # The job name is added as a label `job=` to any timeseries scraped from this config. 23 | - job_name: 'prometheus' 24 | 25 | # metrics_path defaults to '/metrics' 26 | # scheme defaults to 'http'. 27 | 28 | static_configs: 29 | - targets: ['localhost:9090'] 30 | -------------------------------------------------------------------------------- /steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/promtool: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpas/infrastructure-and-system-monitoring-using-prometheus/5e8024b34a5d6e9282ffec6c2e7c4265fd36cf57/steps/1-run-prometheus-native/prometheus-2.2.1.darwin-amd64/promtool -------------------------------------------------------------------------------- /steps/2-run-prometheus-using-docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ -------------------------------------------------------------------------------- /steps/2-run-prometheus-using-docker/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | -------------------------------------------------------------------------------- /steps/3-add-host-metrics/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | node-exporter: 13 | image: prom/node-exporter:latest 14 | container_name: node-exporter 15 | ports: 16 | - '9100:9100' 17 | -------------------------------------------------------------------------------- /steps/3-add-host-metrics/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | 29 | # The job name is added as a label `job=` to any timeseries scraped from this config. 30 | - job_name: 'node-exporter' 31 | 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | 35 | static_configs: 36 | - targets: ['node-exporter:9100'] -------------------------------------------------------------------------------- /steps/4-grafana/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | node-exporter: 13 | image: prom/node-exporter:latest 14 | container_name: node-exporter 15 | ports: 16 | - '9100:9100' 17 | 18 | grafana: 19 | image: grafana/grafana:latest 20 | container_name: grafana 21 | ports: 22 | - "3000:3000" 23 | -------------------------------------------------------------------------------- /steps/4-grafana/node-exporter-single-server_rev7.json: -------------------------------------------------------------------------------- 1 | { 2 | "__inputs": [ 3 | { 4 | "name": "DS_PROMETHEUS", 5 | "label": "Prometheus", 6 | "description": "", 7 | "type": "datasource", 8 | "pluginId": "prometheus", 9 | "pluginName": "Prometheus" 10 | } 11 | ], 12 | "__requires": [ 13 | { 14 | "type": "panel", 15 | "id": "graph", 16 | "name": "Graph", 17 | "version": "" 18 | }, 19 | { 20 | "type": "panel", 21 | "id": "singlestat", 22 | "name": "Singlestat", 23 | "version": "" 24 | }, 25 | { 26 | "type": "grafana", 27 | "id": "grafana", 28 | "name": "Grafana", 29 | "version": "3.1.0" 30 | }, 31 | { 32 | "type": "datasource", 33 | "id": "prometheus", 34 | "name": "Prometheus", 35 | "version": "1.0.0" 36 | } 37 | ], 38 | "id": null, 39 | "title": "Node exporter single server", 40 | "description": "Dashboard to get an overview of one server", 41 | "tags": [ 42 | "prometheus" 43 | ], 44 | "style": "dark", 45 | "timezone": "browser", 46 | "editable": true, 47 | "hideControls": false, 48 | "sharedCrosshair": false, 49 | "rows": [ 50 | { 51 | "collapse": false, 52 | "editable": true, 53 | "height": "250px", 54 | "panels": [ 55 | { 56 | "aliasColors": {}, 57 | "bars": false, 58 | "datasource": "${DS_PROMETHEUS}", 59 | "editable": true, 60 | "error": false, 61 | "fill": 1, 62 | "grid": { 63 | "threshold1": null, 64 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 65 | "threshold2": null, 66 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 67 | }, 68 | "id": 3, 69 | "isNew": true, 70 | "legend": { 71 | "avg": false, 72 | "current": false, 73 | "max": false, 74 | "min": false, 75 | "show": true, 76 | "total": false, 77 | "values": false 78 | }, 79 | "lines": true, 80 | "linewidth": 2, 81 | "links": [], 82 | "nullPointMode": "connected", 83 | "percentage": false, 84 | "pointradius": 5, 85 | "points": false, 86 | "renderer": "flot", 87 | "seriesOverrides": [], 88 | "span": 6, 89 | "stack": false, 90 | "steppedLine": false, 91 | "targets": [ 92 | { 93 | "expr": "100 - (avg by (cpu) (irate(node_cpu{mode=\"idle\", instance=~\"$server\"}[5m])) * 100)", 94 | "hide": false, 95 | "intervalFactor": 10, 96 | "legendFormat": "{{cpu}}", 97 | "refId": "A", 98 | "step": 20 99 | } 100 | ], 101 | "timeFrom": null, 102 | "timeShift": null, 103 | "title": "Idle cpu", 104 | "tooltip": { 105 | "msResolution": false, 106 | "shared": true, 107 | "sort": 0, 108 | "value_type": "cumulative" 109 | }, 110 | "type": "graph", 111 | "xaxis": { 112 | "show": true 113 | }, 114 | "yaxes": [ 115 | { 116 | "format": "percent", 117 | "label": "cpu usage", 118 | "logBase": 1, 119 | "max": 100, 120 | "min": 0, 121 | "show": true 122 | }, 123 | { 124 | "format": "short", 125 | "label": null, 126 | "logBase": 1, 127 | "max": null, 128 | "min": null, 129 | "show": true 130 | } 131 | ] 132 | }, 133 | { 134 | "aliasColors": {}, 135 | "bars": false, 136 | "datasource": "${DS_PROMETHEUS}", 137 | "editable": true, 138 | "error": false, 139 | "fill": 1, 140 | "grid": { 141 | "threshold1": null, 142 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 143 | "threshold2": null, 144 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 145 | }, 146 | "id": 9, 147 | "isNew": true, 148 | "legend": { 149 | "avg": false, 150 | "current": false, 151 | "max": false, 152 | "min": false, 153 | "show": true, 154 | "total": false, 155 | "values": false 156 | }, 157 | "lines": true, 158 | "linewidth": 2, 159 | "links": [], 160 | "nullPointMode": "connected", 161 | "percentage": false, 162 | "pointradius": 5, 163 | "points": false, 164 | "renderer": "flot", 165 | "seriesOverrides": [], 166 | "span": 6, 167 | "stack": false, 168 | "steppedLine": false, 169 | "targets": [ 170 | { 171 | "expr": "node_load1{instance=~\"$server\"}", 172 | "intervalFactor": 4, 173 | "legendFormat": "load 1m", 174 | "refId": "A", 175 | "step": 8, 176 | "target": "" 177 | }, 178 | { 179 | "expr": "node_load5{instance=~\"$server\"}", 180 | "intervalFactor": 4, 181 | "legendFormat": "load 5m", 182 | "refId": "B", 183 | "step": 8, 184 | "target": "" 185 | }, 186 | { 187 | "expr": "node_load15{instance=~\"$server\"}", 188 | "intervalFactor": 4, 189 | "legendFormat": "load 15m", 190 | "refId": "C", 191 | "step": 8, 192 | "target": "" 193 | } 194 | ], 195 | "timeFrom": null, 196 | "timeShift": null, 197 | "title": "System load", 198 | "tooltip": { 199 | "msResolution": false, 200 | "shared": true, 201 | "sort": 0, 202 | "value_type": "cumulative" 203 | }, 204 | "type": "graph", 205 | "xaxis": { 206 | "show": true 207 | }, 208 | "yaxes": [ 209 | { 210 | "format": "percentunit", 211 | "label": null, 212 | "logBase": 1, 213 | "max": null, 214 | "min": null, 215 | "show": true 216 | }, 217 | { 218 | "format": "short", 219 | "label": null, 220 | "logBase": 1, 221 | "max": null, 222 | "min": null, 223 | "show": true 224 | } 225 | ] 226 | } 227 | ], 228 | "title": "New row" 229 | }, 230 | { 231 | "collapse": false, 232 | "editable": true, 233 | "height": "250px", 234 | "panels": [ 235 | { 236 | "aliasColors": {}, 237 | "bars": false, 238 | "datasource": "${DS_PROMETHEUS}", 239 | "editable": true, 240 | "error": false, 241 | "fill": 1, 242 | "grid": { 243 | "threshold1": null, 244 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 245 | "threshold2": null, 246 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 247 | }, 248 | "id": 4, 249 | "isNew": true, 250 | "legend": { 251 | "avg": false, 252 | "current": false, 253 | "max": false, 254 | "min": false, 255 | "show": true, 256 | "total": false, 257 | "values": false 258 | }, 259 | "lines": true, 260 | "linewidth": 2, 261 | "links": [], 262 | "nullPointMode": "connected", 263 | "percentage": false, 264 | "pointradius": 5, 265 | "points": false, 266 | "renderer": "flot", 267 | "seriesOverrides": [ 268 | { 269 | "alias": "node_memory_SwapFree{instance=\"172.17.0.1:9100\",job=\"prometheus\"}", 270 | "yaxis": 2 271 | } 272 | ], 273 | "span": 10, 274 | "stack": false, 275 | "steppedLine": false, 276 | "targets": [ 277 | { 278 | "expr": "node_memory_MemTotal{instance=~\"$server\"} - node_memory_MemFree{instance=~\"$server\"}", 279 | "intervalFactor": 2, 280 | "legendFormat": "free memory", 281 | "metric": "memo", 282 | "refId": "A", 283 | "step": 4, 284 | "target": "" 285 | } 286 | ], 287 | "timeFrom": null, 288 | "timeShift": null, 289 | "title": "Free memory", 290 | "tooltip": { 291 | "msResolution": false, 292 | "shared": true, 293 | "sort": 0, 294 | "value_type": "cumulative" 295 | }, 296 | "type": "graph", 297 | "xaxis": { 298 | "show": true 299 | }, 300 | "yaxes": [ 301 | { 302 | "format": "bytes", 303 | "label": null, 304 | "logBase": 1, 305 | "max": null, 306 | "min": null, 307 | "show": true 308 | }, 309 | { 310 | "format": "short", 311 | "label": null, 312 | "logBase": 1, 313 | "max": null, 314 | "min": null, 315 | "show": true 316 | } 317 | ] 318 | }, 319 | { 320 | "cacheTimeout": null, 321 | "colorBackground": false, 322 | "colorValue": false, 323 | "colors": [ 324 | "rgba(245, 54, 54, 0.9)", 325 | "rgba(237, 129, 40, 0.89)", 326 | "rgba(50, 172, 45, 0.97)" 327 | ], 328 | "datasource": "${DS_PROMETHEUS}", 329 | "editable": true, 330 | "error": false, 331 | "format": "percent", 332 | "gauge": { 333 | "maxValue": 100, 334 | "minValue": 0, 335 | "show": true, 336 | "thresholdLabels": false, 337 | "thresholdMarkers": true 338 | }, 339 | "id": 5, 340 | "interval": null, 341 | "isNew": true, 342 | "links": [], 343 | "mappingType": 1, 344 | "mappingTypes": [ 345 | { 346 | "name": "value to text", 347 | "value": 1 348 | }, 349 | { 350 | "name": "range to text", 351 | "value": 2 352 | } 353 | ], 354 | "maxDataPoints": 100, 355 | "nullPointMode": "connected", 356 | "nullText": null, 357 | "postfix": "", 358 | "postfixFontSize": "50%", 359 | "prefix": "", 360 | "prefixFontSize": "50%", 361 | "rangeMaps": [ 362 | { 363 | "from": "null", 364 | "text": "N/A", 365 | "to": "null" 366 | } 367 | ], 368 | "span": 2, 369 | "sparkline": { 370 | "fillColor": "rgba(31, 118, 189, 0.18)", 371 | "full": false, 372 | "lineColor": "rgb(31, 120, 193)", 373 | "show": false 374 | }, 375 | "targets": [ 376 | { 377 | "expr": "(node_memory_MemFree{instance=~\"$server\"} / node_memory_MemTotal{instance=~\"$server\"}) * 100", 378 | "intervalFactor": 2, 379 | "refId": "A", 380 | "step": 60, 381 | "target": "" 382 | } 383 | ], 384 | "thresholds": "10, 20", 385 | "title": "Free memory", 386 | "type": "singlestat", 387 | "valueFontSize": "80%", 388 | "valueMaps": [ 389 | { 390 | "op": "=", 391 | "text": "N/A", 392 | "value": "null" 393 | } 394 | ], 395 | "valueName": "avg" 396 | } 397 | ], 398 | "title": "New row" 399 | }, 400 | { 401 | "collapse": false, 402 | "editable": true, 403 | "height": "250px", 404 | "panels": [ 405 | { 406 | "aliasColors": {}, 407 | "bars": false, 408 | "datasource": "${DS_PROMETHEUS}", 409 | "editable": true, 410 | "error": false, 411 | "fill": 1, 412 | "grid": { 413 | "threshold1": null, 414 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 415 | "threshold2": null, 416 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 417 | }, 418 | "id": 6, 419 | "isNew": true, 420 | "legend": { 421 | "avg": false, 422 | "current": false, 423 | "max": false, 424 | "min": false, 425 | "show": true, 426 | "total": false, 427 | "values": false 428 | }, 429 | "lines": true, 430 | "linewidth": 2, 431 | "links": [], 432 | "nullPointMode": "connected", 433 | "percentage": false, 434 | "pointradius": 5, 435 | "points": false, 436 | "renderer": "flot", 437 | "seriesOverrides": [ 438 | { 439 | "alias": "read", 440 | "yaxis": 1 441 | }, 442 | { 443 | "alias": "{instance=\"172.17.0.1:9100\"}", 444 | "yaxis": 2 445 | }, 446 | { 447 | "alias": "io time", 448 | "yaxis": 2 449 | } 450 | ], 451 | "span": 10, 452 | "stack": false, 453 | "steppedLine": false, 454 | "targets": [ 455 | { 456 | "expr": "sum by (instance) (irate(node_disk_bytes_read{instance=~\"$server\"}[5m]))", 457 | "hide": false, 458 | "intervalFactor": 4, 459 | "legendFormat": "read", 460 | "refId": "A", 461 | "step": 8, 462 | "target": "" 463 | }, 464 | { 465 | "expr": "sum by (instance) (irate(node_disk_bytes_written{instance=~\"$server\"}[5m]))", 466 | "intervalFactor": 4, 467 | "legendFormat": "written", 468 | "refId": "B", 469 | "step": 8 470 | }, 471 | { 472 | "expr": "sum by (instance) (irate(node_disk_io_time_ms{instance=~\"$server\"}[5m]))", 473 | "intervalFactor": 4, 474 | "legendFormat": "io time", 475 | "refId": "C", 476 | "step": 8 477 | } 478 | ], 479 | "timeFrom": null, 480 | "timeShift": null, 481 | "title": "Disk usage", 482 | "tooltip": { 483 | "msResolution": false, 484 | "shared": true, 485 | "sort": 0, 486 | "value_type": "cumulative" 487 | }, 488 | "type": "graph", 489 | "xaxis": { 490 | "show": true 491 | }, 492 | "yaxes": [ 493 | { 494 | "format": "bytes", 495 | "label": null, 496 | "logBase": 1, 497 | "max": null, 498 | "min": null, 499 | "show": true 500 | }, 501 | { 502 | "format": "ms", 503 | "label": null, 504 | "logBase": 1, 505 | "max": null, 506 | "min": null, 507 | "show": true 508 | } 509 | ] 510 | }, 511 | { 512 | "cacheTimeout": null, 513 | "colorBackground": false, 514 | "colorValue": false, 515 | "colors": [ 516 | "rgba(245, 54, 54, 0.9)", 517 | "rgba(237, 129, 40, 0.89)", 518 | "rgba(50, 172, 45, 0.97)" 519 | ], 520 | "datasource": "${DS_PROMETHEUS}", 521 | "editable": true, 522 | "error": false, 523 | "format": "percentunit", 524 | "gauge": { 525 | "maxValue": 1, 526 | "minValue": 0, 527 | "show": true, 528 | "thresholdLabels": false, 529 | "thresholdMarkers": true 530 | }, 531 | "id": 7, 532 | "interval": null, 533 | "isNew": true, 534 | "links": [], 535 | "mappingType": 1, 536 | "mappingTypes": [ 537 | { 538 | "name": "value to text", 539 | "value": 1 540 | }, 541 | { 542 | "name": "range to text", 543 | "value": 2 544 | } 545 | ], 546 | "maxDataPoints": 100, 547 | "nullPointMode": "connected", 548 | "nullText": null, 549 | "postfix": "", 550 | "postfixFontSize": "50%", 551 | "prefix": "", 552 | "prefixFontSize": "50%", 553 | "rangeMaps": [ 554 | { 555 | "from": "null", 556 | "text": "N/A", 557 | "to": "null" 558 | } 559 | ], 560 | "span": 2, 561 | "sparkline": { 562 | "fillColor": "rgba(31, 118, 189, 0.18)", 563 | "full": false, 564 | "lineColor": "rgb(31, 120, 193)", 565 | "show": false 566 | }, 567 | "targets": [ 568 | { 569 | "expr": "min(node_filesystem_free{device!=\"rootfs\",instance=~\"$server\"} / node_filesystem_size{device!=\"rootfs\",instance=~\"$server\"})", 570 | "intervalFactor": 2, 571 | "refId": "A", 572 | "step": 60, 573 | "target": "" 574 | } 575 | ], 576 | "thresholds": "0.10, 0.25", 577 | "title": "Free disk space (lowest mountpoint)", 578 | "type": "singlestat", 579 | "valueFontSize": "80%", 580 | "valueMaps": [ 581 | { 582 | "op": "=", 583 | "text": "N/A", 584 | "value": "null" 585 | } 586 | ], 587 | "valueName": "current" 588 | } 589 | ], 590 | "title": "New row" 591 | }, 592 | { 593 | "collapse": false, 594 | "editable": true, 595 | "height": "250px", 596 | "panels": [ 597 | { 598 | "aliasColors": {}, 599 | "bars": false, 600 | "datasource": "${DS_PROMETHEUS}", 601 | "editable": true, 602 | "error": false, 603 | "fill": 1, 604 | "grid": { 605 | "threshold1": null, 606 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 607 | "threshold2": null, 608 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 609 | }, 610 | "id": 8, 611 | "isNew": true, 612 | "legend": { 613 | "avg": false, 614 | "current": false, 615 | "max": false, 616 | "min": false, 617 | "show": true, 618 | "total": false, 619 | "values": false 620 | }, 621 | "lines": true, 622 | "linewidth": 2, 623 | "links": [], 624 | "nullPointMode": "connected", 625 | "percentage": false, 626 | "pointradius": 5, 627 | "points": false, 628 | "renderer": "flot", 629 | "seriesOverrides": [ 630 | { 631 | "alias": "transmitted ", 632 | "yaxis": 2 633 | } 634 | ], 635 | "span": 12, 636 | "stack": false, 637 | "steppedLine": false, 638 | "targets": [ 639 | { 640 | "expr": "irate(node_network_receive_bytes{instance=~\"$server\",device!~\"lo\"}[5m])", 641 | "hide": false, 642 | "intervalFactor": 2, 643 | "legendFormat": "received", 644 | "refId": "A", 645 | "step": 2, 646 | "target": "" 647 | }, 648 | { 649 | "expr": "irate(node_network_transmit_bytes{instance=~\"$server\",device!~\"lo\"}[5m])", 650 | "hide": false, 651 | "intervalFactor": 2, 652 | "legendFormat": "transmitted ", 653 | "refId": "B", 654 | "step": 2, 655 | "target": "" 656 | }, 657 | { 658 | "expr": "node_network_transmit_bytes{instance=~\"$server\",device!~\"lo\"}", 659 | "hide": true, 660 | "intervalFactor": 2, 661 | "legendFormat": "transmitted ", 662 | "refId": "C", 663 | "step": 2, 664 | "target": "" 665 | } 666 | ], 667 | "timeFrom": null, 668 | "timeShift": null, 669 | "title": "Data transfer", 670 | "tooltip": { 671 | "msResolution": false, 672 | "shared": true, 673 | "sort": 0, 674 | "value_type": "cumulative" 675 | }, 676 | "type": "graph", 677 | "xaxis": { 678 | "show": true 679 | }, 680 | "yaxes": [ 681 | { 682 | "format": "bytes", 683 | "label": null, 684 | "logBase": 1, 685 | "max": null, 686 | "min": null, 687 | "show": true 688 | }, 689 | { 690 | "format": "bytes", 691 | "label": null, 692 | "logBase": 1, 693 | "max": null, 694 | "min": null, 695 | "show": true 696 | } 697 | ] 698 | } 699 | ], 700 | "title": "New row" 701 | } 702 | ], 703 | "time": { 704 | "from": "now-1h", 705 | "to": "now" 706 | }, 707 | "timepicker": { 708 | "refresh_intervals": [ 709 | "5s", 710 | "10s", 711 | "30s", 712 | "1m", 713 | "5m", 714 | "15m", 715 | "30m", 716 | "1h", 717 | "2h", 718 | "1d" 719 | ], 720 | "time_options": [ 721 | "5m", 722 | "15m", 723 | "1h", 724 | "6h", 725 | "12h", 726 | "24h", 727 | "2d", 728 | "7d", 729 | "30d" 730 | ] 731 | }, 732 | "templating": { 733 | "list": [ 734 | { 735 | "current": {}, 736 | "datasource": "${DS_PROMETHEUS}", 737 | "hide": 0, 738 | "includeAll": false, 739 | "multi": false, 740 | "name": "server", 741 | "options": [], 742 | "query": "label_values(node_boot_time, instance)", 743 | "refresh": 1, 744 | "type": "query" 745 | } 746 | ] 747 | }, 748 | "annotations": { 749 | "list": [] 750 | }, 751 | "refresh": false, 752 | "schemaVersion": 12, 753 | "version": 8, 754 | "links": [], 755 | "gnetId": 22 756 | } -------------------------------------------------------------------------------- /steps/4-grafana/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | 29 | # The job name is added as a label `job=` to any timeseries scraped from this config. 30 | - job_name: 'node-exporter' 31 | 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | 35 | static_configs: 36 | - targets: ['node-exporter:9100'] -------------------------------------------------------------------------------- /steps/5-monitor-docker-containers/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | node-exporter: 13 | image: prom/node-exporter:latest 14 | container_name: node-exporter 15 | ports: 16 | - '9100:9100' 17 | 18 | grafana: 19 | image: grafana/grafana:latest 20 | container_name: grafana 21 | ports: 22 | - "3000:3000" 23 | 24 | cadvisor: 25 | image: google/cadvisor:latest 26 | container_name: cadvisor 27 | ports: 28 | - "8095:8080" 29 | volumes: 30 | - /:/rootfs:ro 31 | - /var/run:/var/run:rw 32 | - /sys:/sys:ro 33 | - /var/lib/docker/:/var/lib/docker:ro 34 | -------------------------------------------------------------------------------- /steps/5-monitor-docker-containers/docker-dashboard_rev5.json: -------------------------------------------------------------------------------- 1 | { 2 | "__inputs": [ 3 | { 4 | "name": "DS_PROMETHEUS", 5 | "label": "Prometheus", 6 | "description": "", 7 | "type": "datasource", 8 | "pluginId": "prometheus", 9 | "pluginName": "Prometheus" 10 | } 11 | ], 12 | "__requires": [ 13 | { 14 | "type": "panel", 15 | "id": "singlestat", 16 | "name": "Singlestat", 17 | "version": "" 18 | }, 19 | { 20 | "type": "panel", 21 | "id": "graph", 22 | "name": "Graph", 23 | "version": "" 24 | }, 25 | { 26 | "type": "grafana", 27 | "id": "grafana", 28 | "name": "Grafana", 29 | "version": "3.1.0" 30 | }, 31 | { 32 | "type": "datasource", 33 | "id": "prometheus", 34 | "name": "Prometheus", 35 | "version": "1.0.0" 36 | } 37 | ], 38 | "id": null, 39 | "title": "Docker Dashboard", 40 | "description": "Docker Monitoring Template", 41 | "tags": [ 42 | "docker" 43 | ], 44 | "style": "dark", 45 | "timezone": "browser", 46 | "editable": true, 47 | "hideControls": false, 48 | "sharedCrosshair": true, 49 | "rows": [ 50 | { 51 | "collapse": false, 52 | "editable": true, 53 | "height": "250px", 54 | "panels": [ 55 | { 56 | "cacheTimeout": null, 57 | "colorBackground": false, 58 | "colorValue": false, 59 | "colors": [ 60 | "rgba(50, 172, 45, 0.97)", 61 | "rgba(237, 129, 40, 0.89)", 62 | "rgba(245, 54, 54, 0.9)" 63 | ], 64 | "datasource": "${DS_PROMETHEUS}", 65 | "editable": true, 66 | "error": false, 67 | "format": "percent", 68 | "gauge": { 69 | "maxValue": 100, 70 | "minValue": 0, 71 | "show": true, 72 | "thresholdLabels": false, 73 | "thresholdMarkers": true 74 | }, 75 | "id": 4, 76 | "interval": null, 77 | "isNew": true, 78 | "links": [], 79 | "mappingType": 1, 80 | "mappingTypes": [ 81 | { 82 | "name": "value to text", 83 | "value": 1 84 | }, 85 | { 86 | "name": "range to text", 87 | "value": 2 88 | } 89 | ], 90 | "maxDataPoints": 100, 91 | "nullPointMode": "connected", 92 | "nullText": null, 93 | "postfix": "", 94 | "postfixFontSize": "50%", 95 | "prefix": "", 96 | "prefixFontSize": "50%", 97 | "rangeMaps": [ 98 | { 99 | "from": "null", 100 | "text": "N/A", 101 | "to": "null" 102 | } 103 | ], 104 | "span": 4, 105 | "sparkline": { 106 | "fillColor": "rgba(31, 118, 189, 0.18)", 107 | "full": false, 108 | "lineColor": "rgb(31, 120, 193)", 109 | "show": false 110 | }, 111 | "targets": [ 112 | { 113 | "expr": "(sum(node_memory_MemTotal) - sum(node_memory_MemFree+node_memory_Buffers+node_memory_Cached) ) / sum(node_memory_MemTotal) * 100", 114 | "interval": "10s", 115 | "intervalFactor": 1, 116 | "refId": "A", 117 | "step": 10 118 | } 119 | ], 120 | "thresholds": "65, 90", 121 | "title": "Memory usage", 122 | "type": "singlestat", 123 | "valueFontSize": "80%", 124 | "valueMaps": [ 125 | { 126 | "op": "=", 127 | "text": "N/A", 128 | "value": "null" 129 | } 130 | ], 131 | "valueName": "current" 132 | }, 133 | { 134 | "cacheTimeout": null, 135 | "colorBackground": false, 136 | "colorValue": false, 137 | "colors": [ 138 | "rgba(50, 172, 45, 0.97)", 139 | "rgba(237, 129, 40, 0.89)", 140 | "rgba(245, 54, 54, 0.9)" 141 | ], 142 | "datasource": "${DS_PROMETHEUS}", 143 | "decimals": 2, 144 | "editable": true, 145 | "error": false, 146 | "format": "percent", 147 | "gauge": { 148 | "maxValue": 100, 149 | "minValue": 0, 150 | "show": true, 151 | "thresholdLabels": false, 152 | "thresholdMarkers": true 153 | }, 154 | "id": 6, 155 | "interval": null, 156 | "isNew": true, 157 | "links": [], 158 | "mappingType": 1, 159 | "mappingTypes": [ 160 | { 161 | "name": "value to text", 162 | "value": 1 163 | }, 164 | { 165 | "name": "range to text", 166 | "value": 2 167 | } 168 | ], 169 | "maxDataPoints": 100, 170 | "nullPointMode": "connected", 171 | "nullText": null, 172 | "postfix": "", 173 | "postfixFontSize": "50%", 174 | "prefix": "", 175 | "prefixFontSize": "50%", 176 | "rangeMaps": [ 177 | { 178 | "from": "null", 179 | "text": "N/A", 180 | "to": "null" 181 | } 182 | ], 183 | "span": 4, 184 | "sparkline": { 185 | "fillColor": "rgba(31, 118, 189, 0.18)", 186 | "full": false, 187 | "lineColor": "rgb(31, 120, 193)", 188 | "show": false 189 | }, 190 | "targets": [ 191 | { 192 | "expr": "sum(sum by (container_name)( rate(container_cpu_usage_seconds_total{image!=\"\"}[1m] ) )) / count(node_cpu{mode=\"system\"}) * 100", 193 | "interval": "10s", 194 | "intervalFactor": 1, 195 | "refId": "A", 196 | "step": 10 197 | } 198 | ], 199 | "thresholds": "65, 90", 200 | "title": "CPU usage", 201 | "type": "singlestat", 202 | "valueFontSize": "80%", 203 | "valueMaps": [ 204 | { 205 | "op": "=", 206 | "text": "N/A", 207 | "value": "null" 208 | } 209 | ], 210 | "valueName": "current" 211 | }, 212 | { 213 | "cacheTimeout": null, 214 | "colorBackground": false, 215 | "colorValue": false, 216 | "colors": [ 217 | "rgba(50, 172, 45, 0.97)", 218 | "rgba(237, 129, 40, 0.89)", 219 | "rgba(245, 54, 54, 0.9)" 220 | ], 221 | "datasource": "${DS_PROMETHEUS}", 222 | "decimals": 2, 223 | "editable": true, 224 | "error": false, 225 | "format": "percent", 226 | "gauge": { 227 | "maxValue": 100, 228 | "minValue": 0, 229 | "show": true, 230 | "thresholdLabels": false, 231 | "thresholdMarkers": true 232 | }, 233 | "id": 7, 234 | "interval": null, 235 | "isNew": true, 236 | "links": [], 237 | "mappingType": 1, 238 | "mappingTypes": [ 239 | { 240 | "name": "value to text", 241 | "value": 1 242 | }, 243 | { 244 | "name": "range to text", 245 | "value": 2 246 | } 247 | ], 248 | "maxDataPoints": 100, 249 | "nullPointMode": "connected", 250 | "nullText": null, 251 | "postfix": "", 252 | "postfixFontSize": "50%", 253 | "prefix": "", 254 | "prefixFontSize": "50%", 255 | "rangeMaps": [ 256 | { 257 | "from": "null", 258 | "text": "N/A", 259 | "to": "null" 260 | } 261 | ], 262 | "span": 4, 263 | "sparkline": { 264 | "fillColor": "rgba(31, 118, 189, 0.18)", 265 | "full": false, 266 | "lineColor": "rgb(31, 120, 193)", 267 | "show": false 268 | }, 269 | "targets": [ 270 | { 271 | "expr": "sum (container_fs_limit_bytes - container_fs_usage_bytes) / sum(container_fs_limit_bytes)", 272 | "interval": "10s", 273 | "intervalFactor": 1, 274 | "metric": "", 275 | "refId": "A", 276 | "step": 10 277 | } 278 | ], 279 | "thresholds": "65, 90", 280 | "title": "Filesystem usage", 281 | "type": "singlestat", 282 | "valueFontSize": "80%", 283 | "valueMaps": [ 284 | { 285 | "op": "=", 286 | "text": "N/A", 287 | "value": "null" 288 | } 289 | ], 290 | "valueName": "current" 291 | } 292 | ], 293 | "title": "Row" 294 | }, 295 | { 296 | "collapse": false, 297 | "editable": true, 298 | "height": "250px", 299 | "panels": [ 300 | { 301 | "aliasColors": {}, 302 | "bars": false, 303 | "datasource": "${DS_PROMETHEUS}", 304 | "decimals": 3, 305 | "editable": true, 306 | "error": false, 307 | "fill": 0, 308 | "grid": { 309 | "threshold1": null, 310 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 311 | "threshold2": null, 312 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 313 | }, 314 | "id": 3, 315 | "isNew": true, 316 | "legend": { 317 | "alignAsTable": true, 318 | "avg": true, 319 | "current": true, 320 | "max": false, 321 | "min": false, 322 | "rightSide": true, 323 | "show": true, 324 | "sort": "current", 325 | "sortDesc": true, 326 | "total": false, 327 | "values": true 328 | }, 329 | "lines": true, 330 | "linewidth": 2, 331 | "links": [], 332 | "nullPointMode": "connected", 333 | "percentage": false, 334 | "pointradius": 5, 335 | "points": false, 336 | "renderer": "flot", 337 | "seriesOverrides": [], 338 | "span": 12, 339 | "stack": false, 340 | "steppedLine": false, 341 | "targets": [ 342 | { 343 | "expr": "sort_desc(sum(rate(container_cpu_user_seconds_total{image!=\"\"}[1m])) by (name))", 344 | "interval": "10s", 345 | "intervalFactor": 1, 346 | "legendFormat": "{{ name }}", 347 | "metric": "container_cpu_user_seconds_total", 348 | "refId": "A", 349 | "step": 10 350 | } 351 | ], 352 | "timeFrom": null, 353 | "timeShift": null, 354 | "title": "Container CPU usage", 355 | "tooltip": { 356 | "msResolution": true, 357 | "shared": true, 358 | "sort": 0, 359 | "value_type": "cumulative" 360 | }, 361 | "type": "graph", 362 | "xaxis": { 363 | "show": true 364 | }, 365 | "yaxes": [ 366 | { 367 | "format": "percentunit", 368 | "label": null, 369 | "logBase": 1, 370 | "max": null, 371 | "min": null, 372 | "show": true 373 | }, 374 | { 375 | "format": "short", 376 | "label": null, 377 | "logBase": 1, 378 | "max": null, 379 | "min": null, 380 | "show": true 381 | } 382 | ] 383 | } 384 | ], 385 | "title": "New row" 386 | }, 387 | { 388 | "collapse": false, 389 | "editable": true, 390 | "height": "250px", 391 | "panels": [ 392 | { 393 | "aliasColors": {}, 394 | "bars": false, 395 | "datasource": "${DS_PROMETHEUS}", 396 | "decimals": 2, 397 | "editable": true, 398 | "error": false, 399 | "fill": 0, 400 | "grid": { 401 | "threshold1": null, 402 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 403 | "threshold2": null, 404 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 405 | }, 406 | "id": 2, 407 | "isNew": true, 408 | "legend": { 409 | "alignAsTable": true, 410 | "avg": true, 411 | "current": true, 412 | "max": false, 413 | "min": false, 414 | "rightSide": true, 415 | "show": true, 416 | "sideWidth": 200, 417 | "sort": "current", 418 | "sortDesc": true, 419 | "total": false, 420 | "values": true 421 | }, 422 | "lines": true, 423 | "linewidth": 2, 424 | "links": [], 425 | "nullPointMode": "connected", 426 | "percentage": false, 427 | "pointradius": 5, 428 | "points": false, 429 | "renderer": "flot", 430 | "seriesOverrides": [], 431 | "span": 12, 432 | "stack": false, 433 | "steppedLine": false, 434 | "targets": [ 435 | { 436 | "expr": "sort_desc(sum(container_memory_usage_bytes{image!=\"\"}) by (name))", 437 | "interval": "10s", 438 | "intervalFactor": 1, 439 | "legendFormat": "{{ name }}", 440 | "metric": "container_memory_usage:sort_desc", 441 | "refId": "A", 442 | "step": 10 443 | } 444 | ], 445 | "timeFrom": null, 446 | "timeShift": null, 447 | "title": "Container Memory Usage", 448 | "tooltip": { 449 | "msResolution": false, 450 | "shared": true, 451 | "sort": 0, 452 | "value_type": "cumulative" 453 | }, 454 | "type": "graph", 455 | "xaxis": { 456 | "show": true 457 | }, 458 | "yaxes": [ 459 | { 460 | "format": "bytes", 461 | "label": null, 462 | "logBase": 1, 463 | "max": null, 464 | "min": null, 465 | "show": true 466 | }, 467 | { 468 | "format": "short", 469 | "label": null, 470 | "logBase": 1, 471 | "max": null, 472 | "min": null, 473 | "show": true 474 | } 475 | ] 476 | }, 477 | { 478 | "aliasColors": {}, 479 | "bars": false, 480 | "datasource": "${DS_PROMETHEUS}", 481 | "decimals": 2, 482 | "editable": true, 483 | "error": false, 484 | "fill": 0, 485 | "grid": { 486 | "threshold1": null, 487 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 488 | "threshold2": null, 489 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 490 | }, 491 | "id": 8, 492 | "isNew": true, 493 | "legend": { 494 | "alignAsTable": true, 495 | "avg": true, 496 | "current": true, 497 | "max": false, 498 | "min": false, 499 | "rightSide": true, 500 | "show": true, 501 | "sideWidth": 200, 502 | "sort": "current", 503 | "sortDesc": true, 504 | "total": false, 505 | "values": true 506 | }, 507 | "lines": true, 508 | "linewidth": 2, 509 | "links": [], 510 | "nullPointMode": "connected", 511 | "percentage": false, 512 | "pointradius": 5, 513 | "points": false, 514 | "renderer": "flot", 515 | "seriesOverrides": [], 516 | "span": 12, 517 | "stack": false, 518 | "steppedLine": false, 519 | "targets": [ 520 | { 521 | "expr": "sort_desc(sum by (name) (rate(container_network_receive_bytes_total{image!=\"\"}[1m] ) ))", 522 | "interval": "10s", 523 | "intervalFactor": 1, 524 | "legendFormat": "{{ name }}", 525 | "metric": "container_network_receive_bytes_total", 526 | "refId": "A", 527 | "step": 10 528 | } 529 | ], 530 | "timeFrom": null, 531 | "timeShift": null, 532 | "title": "Container Network Input", 533 | "tooltip": { 534 | "msResolution": false, 535 | "shared": true, 536 | "sort": 0, 537 | "value_type": "cumulative" 538 | }, 539 | "type": "graph", 540 | "xaxis": { 541 | "show": true 542 | }, 543 | "yaxes": [ 544 | { 545 | "format": "bytes", 546 | "label": null, 547 | "logBase": 1, 548 | "max": null, 549 | "min": null, 550 | "show": true 551 | }, 552 | { 553 | "format": "short", 554 | "label": null, 555 | "logBase": 1, 556 | "max": null, 557 | "min": null, 558 | "show": true 559 | } 560 | ] 561 | }, 562 | { 563 | "aliasColors": {}, 564 | "bars": false, 565 | "datasource": "${DS_PROMETHEUS}", 566 | "decimals": 2, 567 | "editable": true, 568 | "error": false, 569 | "fill": 0, 570 | "grid": { 571 | "threshold1": null, 572 | "threshold1Color": "rgba(216, 200, 27, 0.27)", 573 | "threshold2": null, 574 | "threshold2Color": "rgba(234, 112, 112, 0.22)" 575 | }, 576 | "id": 9, 577 | "isNew": true, 578 | "legend": { 579 | "alignAsTable": true, 580 | "avg": true, 581 | "current": true, 582 | "max": false, 583 | "min": false, 584 | "rightSide": true, 585 | "show": true, 586 | "sideWidth": 200, 587 | "sort": "current", 588 | "sortDesc": true, 589 | "total": false, 590 | "values": true 591 | }, 592 | "lines": true, 593 | "linewidth": 2, 594 | "links": [], 595 | "nullPointMode": "connected", 596 | "percentage": false, 597 | "pointradius": 5, 598 | "points": false, 599 | "renderer": "flot", 600 | "seriesOverrides": [], 601 | "span": 12, 602 | "stack": false, 603 | "steppedLine": false, 604 | "targets": [ 605 | { 606 | "expr": "sort_desc(sum by (name) (rate(container_network_transmit_bytes_total{image!=\"\"}[1m] ) ))", 607 | "intervalFactor": 2, 608 | "legendFormat": "{{ name }}", 609 | "metric": "container_network_transmit_bytes_total", 610 | "refId": "B", 611 | "step": 4 612 | } 613 | ], 614 | "timeFrom": null, 615 | "timeShift": null, 616 | "title": "Container Network Output", 617 | "tooltip": { 618 | "msResolution": false, 619 | "shared": true, 620 | "sort": 0, 621 | "value_type": "cumulative" 622 | }, 623 | "type": "graph", 624 | "xaxis": { 625 | "show": true 626 | }, 627 | "yaxes": [ 628 | { 629 | "format": "bytes", 630 | "label": null, 631 | "logBase": 1, 632 | "max": null, 633 | "min": null, 634 | "show": true 635 | }, 636 | { 637 | "format": "short", 638 | "label": null, 639 | "logBase": 1, 640 | "max": null, 641 | "min": null, 642 | "show": false 643 | } 644 | ] 645 | } 646 | ], 647 | "title": "New row" 648 | } 649 | ], 650 | "time": { 651 | "from": "now-1h", 652 | "to": "now" 653 | }, 654 | "timepicker": { 655 | "refresh_intervals": [ 656 | "5s", 657 | "10s", 658 | "30s", 659 | "1m", 660 | "5m", 661 | "15m", 662 | "30m", 663 | "1h", 664 | "2h", 665 | "1d" 666 | ], 667 | "time_options": [ 668 | "5m", 669 | "15m", 670 | "1h", 671 | "6h", 672 | "12h", 673 | "24h", 674 | "2d", 675 | "7d", 676 | "30d" 677 | ] 678 | }, 679 | "templating": { 680 | "list": [] 681 | }, 682 | "annotations": { 683 | "list": [] 684 | }, 685 | "refresh": "10s", 686 | "schemaVersion": 12, 687 | "version": 3, 688 | "links": [], 689 | "gnetId": 179 690 | } -------------------------------------------------------------------------------- /steps/5-monitor-docker-containers/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | 29 | # The job name is added as a label `job=` to any timeseries scraped from this config. 30 | - job_name: 'node-exporter' 31 | 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | 35 | static_configs: 36 | - targets: ['node-exporter:9100'] 37 | 38 | # The job name is added as a label `job=` to any timeseries scraped from this config. 39 | - job_name: 'cadvisor' 40 | 41 | # metrics_path defaults to '/metrics' 42 | # scheme defaults to 'http'. 43 | 44 | static_configs: 45 | - targets: ['cadvisor:8080'] -------------------------------------------------------------------------------- /steps/6-alerting/alert.rules: -------------------------------------------------------------------------------- 1 | groups: 2 | - name: containers 3 | rules: 4 | 5 | # Alert for ping instance that is unreachable for 5 seconds 6 | - alert: ping_instance_down 7 | expr: absent(container_memory_usage_bytes{name="ping"}) 8 | for: 5s 9 | labels: 10 | severity: critical 11 | annotations: 12 | summary: "Instance {{ $labels.instance }} down" 13 | description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 seconds." 14 | 15 | - name: host 16 | rules: 17 | - alert: high_cpu_load 18 | expr: node_load1 > 1.5 19 | for: 30s 20 | labels: 21 | severity: warning 22 | annotations: 23 | summary: "Server under high load" 24 | description: "Docker host is under high load, the avg load 1m is at {{ $value}}. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." 25 | 26 | - alert: high_memory_load 27 | expr: (sum(node_memory_MemTotal) - sum(node_memory_MemFree + node_memory_Buffers + node_memory_Cached) ) / sum(node_memory_MemTotal) * 100 > 85 28 | for: 30s 29 | labels: 30 | severity: warning 31 | annotations: 32 | summary: "Server memory is almost full" 33 | description: "Docker host memory usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." 34 | 35 | - alert: high_storage_load 36 | expr: (node_filesystem_size{fstype="aufs"} - node_filesystem_free{fstype="aufs"}) / node_filesystem_size{fstype="aufs"} * 100 > 85 37 | for: 30s 38 | labels: 39 | severity: warning 40 | annotations: 41 | summary: "Server storage is almost full" 42 | description: "Docker host storage usage is {{ humanize $value}}%. Reported by instance {{ $labels.instance }} of job {{ $labels.job }}." 43 | 44 | -------------------------------------------------------------------------------- /steps/6-alerting/config.yml: -------------------------------------------------------------------------------- 1 | global: 2 | smtp_smarthost: 'mailslurper:2500' 3 | smtp_from: 'alertmanager@example.org' 4 | smtp_require_tls: false 5 | 6 | route: 7 | receiver: mail # Fallback 8 | routes: 9 | - match: 10 | severity: critical 11 | continue: true 12 | receiver: mail 13 | - match: 14 | severity: critical 15 | receiver: slack 16 | 17 | receivers: 18 | - name: mail 19 | email_configs: 20 | - send_resolved: true 21 | from: 'foo@bar.acme' 22 | to: 'please-help@bar.acme' 23 | - name: slack 24 | slack_configs: 25 | - send_resolved: true 26 | username: 'AlertManager' 27 | channel: '#devops' 28 | api_url: '' -------------------------------------------------------------------------------- /steps/6-alerting/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | node-exporter: 13 | image: prom/node-exporter:latest 14 | container_name: node-exporter 15 | ports: 16 | - '9100:9100' 17 | 18 | grafana: 19 | image: grafana/grafana:latest 20 | container_name: grafana 21 | ports: 22 | - "3000:3000" 23 | 24 | cadvisor: 25 | image: google/cadvisor:latest 26 | container_name: cadvisor 27 | ports: 28 | - "8095:8080" 29 | volumes: 30 | - /:/rootfs:ro 31 | - /var/run:/var/run:rw 32 | - /sys:/sys:ro 33 | - /var/lib/docker/:/var/lib/docker:ro 34 | 35 | alertmanager: 36 | image: prom/alertmanager 37 | container_name: alertmanager 38 | depends_on: 39 | - "ping" 40 | ports: 41 | - 9093:9093 42 | volumes: 43 | - $PWD:/etc/alertmanager/ 44 | 45 | mailslurper: 46 | image: marcopas/docker-mailslurper 47 | container_name: mailslurper 48 | ports: 49 | - 2500:2500 50 | - 9000:8080 51 | - 8085:8085 52 | volumes: 53 | - $PWD/mailslurper-config.json:/opt/mailslurper/config.json 54 | 55 | ping: 56 | image: alpine 57 | container_name: ping 58 | command: ping localhost 59 | -------------------------------------------------------------------------------- /steps/6-alerting/mailslurper-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "wwwAddress": "0.0.0.0", 3 | "wwwPort": 8080, 4 | "serviceAddress": "0.0.0.0", 5 | "servicePort": 8085, 6 | "smtpAddress": "0.0.0.0", 7 | "smtpPort": 2500, 8 | "dbEngine": "SQLite", 9 | "dbHost": "", 10 | "dbPort": 0, 11 | "dbDatabase": "./mailslurper.db", 12 | "dbUserName": "", 13 | "dbPassword": "", 14 | "maxWorkers": 1000, 15 | "autoStartBrowser": false, 16 | "keyFile": "", 17 | "certFile": "" 18 | } -------------------------------------------------------------------------------- /steps/6-alerting/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | 4 | scrape_interval: 5s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 5 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 6 | # scrape_timeout is set to the global default (10s). 7 | 8 | # Attach these labels to any time series or alerts when communicating with 9 | # external systems (federation, remote storage, Alertmanager). 10 | external_labels: 11 | demo: 'demo-monitor' 12 | 13 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 14 | rule_files: 15 | - "alert.rules" 16 | # - "second.rules" 17 | 18 | # A scrape configuration containing exactly one endpoint to scrape: 19 | # Here it's Prometheus itself. 20 | scrape_configs: 21 | # The job name is added as a label `job=` to any timeseries scraped from this config. 22 | - job_name: 'prometheus' 23 | 24 | # metrics_path defaults to '/metrics' 25 | # scheme defaults to 'http'. 26 | 27 | static_configs: 28 | - targets: ['localhost:9090'] 29 | 30 | # The job name is added as a label `job=` to any timeseries scraped from this config. 31 | - job_name: 'node-exporter' 32 | 33 | # metrics_path defaults to '/metrics' 34 | # scheme defaults to 'http'. 35 | 36 | static_configs: 37 | - targets: ['node-exporter:9100'] 38 | 39 | # The job name is added as a label `job=` to any timeseries scraped from this config. 40 | - job_name: 'cadvisor' 41 | 42 | # metrics_path defaults to '/metrics' 43 | # scheme defaults to 'http'. 44 | 45 | static_configs: 46 | - targets: ['cadvisor:8080'] 47 | 48 | alerting: 49 | alertmanagers: 50 | - scheme: http 51 | static_configs: 52 | - targets: 53 | - 'alertmanager:9093' -------------------------------------------------------------------------------- /steps/7-adding-application-metrics/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | springboot: 13 | image: spring-boot-prometheus-demo 14 | container_name: spring-boot-prometheus-demo 15 | ports: 16 | - "8081:8080" 17 | environment: 18 | - server.port=8080 -------------------------------------------------------------------------------- /steps/7-adding-application-metrics/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | 29 | # The job name is added as a label `job=` to any timeseries scraped from this config. 30 | - job_name: 'springboot' 31 | 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | metrics_path: '/prometheus' 35 | 36 | static_configs: 37 | - targets: ['springboot:8080'] -------------------------------------------------------------------------------- /steps/8-consul-integration/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | 4 | prometheus: 5 | image: prom/prometheus:latest 6 | container_name: prometheus 7 | ports: 8 | - "9090:9090" 9 | volumes: 10 | - $PWD:/etc/prometheus/ 11 | 12 | consul: 13 | image: consul 14 | ports: 15 | - "8500:8500" 16 | 17 | springboot1: 18 | image: spring-boot-prometheus-demo:latest 19 | ports: 20 | - "8081:8080" 21 | environment: 22 | - server.port=8080 23 | 24 | springboot2: 25 | image: spring-boot-prometheus-demo:latest 26 | ports: 27 | - "8082:8080" 28 | environment: 29 | - server.port=8080 30 | -------------------------------------------------------------------------------- /steps/8-consul-integration/prometheus.yml: -------------------------------------------------------------------------------- 1 | # my global config 2 | global: 3 | scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 4 | evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 5 | # scrape_timeout is set to the global default (10s). 6 | 7 | # Attach these labels to any time series or alerts when communicating with 8 | # external systems (federation, remote storage, Alertmanager). 9 | external_labels: 10 | demo: 'demo-monitor' 11 | 12 | # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. 13 | rule_files: 14 | # - "first.rules" 15 | # - "second.rules" 16 | 17 | # A scrape configuration containing exactly one endpoint to scrape: 18 | # Here it's Prometheus itself. 19 | scrape_configs: 20 | # The job name is added as a label `job=` to any timeseries scraped from this config. 21 | - job_name: 'prometheus' 22 | 23 | # metrics_path defaults to '/metrics' 24 | # scheme defaults to 'http'. 25 | 26 | static_configs: 27 | - targets: ['localhost:9090'] 28 | 29 | # The job name is added as a label `job=` to any timeseries scraped from this config. 30 | - job_name: 'consul-services' 31 | 32 | # metrics_path defaults to '/metrics' 33 | # scheme defaults to 'http'. 34 | metrics_path: '/prometheus' 35 | 36 | consul_sd_configs: 37 | - server: 'consul:8500' 38 | services: ['service1', 'service2'] -------------------------------------------------------------------------------- /steps/8-consul-integration/register-service1.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "service1", 3 | "address": "springboot1", 4 | "port": 8080, 5 | "check": { 6 | "id": "api", 7 | "name": "HTTP API on port 8080", 8 | "http": "http://springboot1:8080/health", 9 | "interval": "10s", 10 | "timeout": "1s" 11 | } 12 | } -------------------------------------------------------------------------------- /steps/8-consul-integration/register-service2.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "service2", 3 | "address": "springboot2", 4 | "port": 8080, 5 | "check": { 6 | "id": "api", 7 | "name": "HTTP API on port 8080", 8 | "http": "http://springboot2:8080/health", 9 | "interval": "10s", 10 | "timeout": "1s" 11 | } 12 | } -------------------------------------------------------------------------------- /steps/8-consul-integration/register-services-with-consul.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | http PUT http://localhost:8500/v1/agent/service/register < register-service1.json 3 | http PUT http://localhost:8500/v1/agent/service/register < register-service2.json --------------------------------------------------------------------------------
    PrometheusUpIngested SamplesMemory
    {{ .Labels.instance }}Yes{{ else }} class="alert-danger">No{{ end }}{{ template "prom_query_drilldown" (args (printf "irate(prometheus_tsdb_head_samples_appended_total{job='prometheus',instance='%s'}[5m])" .Labels.instance) "/s" "humanizeNoSmallPrefix") }}{{ template "prom_query_drilldown" (args (printf "process_resident_memory_bytes{job='prometheus',instance='%s'}" .Labels.instance) "B" "humanize1024")}}
    No devices found.