Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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 / 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 / pcf-rtr-logs-saved-objects-7x.json
Last active September 7, 2019 01:39
PCF RTR Logs Kibana Saved Objects
[
{
"_id": "af6e3990-870a-11e9-808a-77559368a0be",
"_type": "dashboard",
"_source": {
"title": "pcf-rtr-dashboard",
"hits": 0,
"description": "",
"panelsJSON": "[{\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"1\"},\"version\":\"7.0.0\",\"panelIndex\":\"1\",\"embeddableConfig\":{},\"panelRefName\":\"panel_0\"},{\"gridData\":{\"x\":24,\"y\":0,\"w\":24,\"h\":15,\"i\":\"2\"},\"version\":\"7.0.0\",\"panelIndex\":\"2\",\"embeddableConfig\":{},\"panelRefName\":\"panel_1\"},{\"gridData\":{\"x\":0,\"y\":46,\"w\":48,\"h\":15,\"i\":\"3\"},\"version\":\"7.0.0\",\"panelIndex\":\"3\",\"embeddableConfig\":{},\"panelRefName\":\"panel_2\"},{\"gridData\":{\"x\":0,\"y\":15,\"w\":48,\"h\":15,\"i\":\"4\"},\"version\":\"7.0.0\",\"panelIndex\":\"4\",\"embeddableConfig\":{},\"panelRefName\":\"panel_3\"},{\"gridData\":{\"x\":0,\"y\":30,\"w\":48,\"h\":16,\"i\":\"5\"},\"version\":\"7.0.0\",\"panelIndex\":\"5\",\"embeddableConfig\":{},\"panelRefName\":\"panel_4\"}]",
"optionsJSON": "
@bvader
bvader / PCF-Space-Drain-ELK-Stack-Quick-Start.txt
Last active September 11, 2019 15:56
Quick Start for PCF, Space Drain and ELK Stack
##
# Assumes Basic Understanding of PCF, Elasticsearch, Kibana and logstash
# Should support Elasticstack 7.X
##
##
# Step 1: Setup index template
# Save this file https://gist.github.com/bvader/addf80083b170e0cfcd78f946a78d50e
# to pcf_space_drain_log_template.json
# Then run the following command replacing the username, password and elasticearchhost
---
version: '2.2'
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:
1) Prerequisite : Properly configured Hot / Warm Elasticsearch cluster with correct node attributes.
2) Configure Metricbeat to point directly to Elasticsearch and run setup
NOTE: When metricbeat setup is run, it will overwrite the ILM Policy and recreate the bootstrap index with that policy,
this is often confusing. Running setup also creates all the dashboards, index templates etc. so it is very useful.
As part of the template it will name the ILM policy and rollover_alias in this example metricbeat-7.4.0
./metricbeat setup