Skip to content

Instantly share code, notes, and snippets.

@bvader
bvader / elastic-apm-quickdemo.txt
Last active December 5, 2019 23:41
Quick Demo Java APM Elastic
# User docker compose to stand up whole stack Elasticsearch, Kibana and APM server
# You can ^C to stop afterwards you can use `start` and `stop` commands
# THIS IS NOT A PRODUCTION SETUP
# Docker compose file elastic-apm-compose.yml found here : https://gist.github.com/bvader/9665fa7b3bd69457517e41a7c28b4725
TAG=7.3.0 docker-compose -f elastic-apm-compose.yml up
# After the stack is full running please go to
http://localhost:5601/app/kibana#/home/tutorial/apm?_g=()
@bvader
bvader / elastic-apm-compose.yml
Last active February 4, 2020 18:47
Elastic APM Quickstack
---
version: '3.1'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
environment: ['ES_JAVA_OPTS=-Xms2g -Xmx2g','bootstrap.memory_lock=true','discovery.type=single-node', 'http.host=0.0.0.0', 'transport.host=127.0.0.1']
ports: ['127.0.0.1:9200:9200']
networks: ['stack']
ulimits:
memlock:
@bvader
bvader / heartbeat_uptime_percent.json
Last active May 23, 2019 01:06
Heartbeat Uptime Percentage Calculator
# New 7.x for computing uptime percentage by URL
# Note you can change the timestamp range and interval as needed.
# Right now this aggs on "url.domain" but could / should be "monitor.name" or "monitor.id"
POST /heartbeat-*/_search?size=0
{
"query": {
"range": {
"@timestamp": {
"gte": "now-24h/h",
"lte": "now/h"
@bvader
bvader / setup-spring-petclinic-rest-apm.txt
Last active September 27, 2018 04:33
Setup Spring Petclinic Rest with Elastic APM Agent
###
# I am not a Maven Guru so I am sure there is a better way to do the copy in the pom.xml
# But I am demonstrating that java apm agent is not required at compile time
# the java apm agent should probably be installed / pulled from a local or maven repo
# In PCF the entire app and app agent need to be deployed
# There are some subtleties with PCF that I will not go into here
###
#
@bvader
bvader / application.properties
Created September 27, 2018 04:09
spring-petclinic-rest:src/main/resources/application.properties
# active profiles config
#
# application use two active profiles
#
# one for select repository layer
# ------------------------------------------------
# When using HSQL, use: hsqldb
# When using MySQL, use: mysql
# When using PostgeSQL, use: postgresql
# ------------------------------------------------
@bvader
bvader / application-mysql.properties
Created September 27, 2018 04:06
spring-petclinic-rest:src/main/resources/application-mysql.properties
# uncomment for init database (first start)
spring.datasource.initialize=true
spring.datasource.schema=classpath*:db/mysql/initDB.sql
spring.datasource.data=classpath*:db/mysql/populateDB.sql
# MySQL config start
#----------------------------------------------------------------
spring.datasource.url = jdbc:mysql://localhost:3306/petclinic?useUnicode=true
spring.datasource.username=root
spring.datasource.password=petclinic