Synthetics: Proactive Problem Detection
Elastic is excited to introduce Synthetic monitoring to our Uptime solution. This allows for more advanced uptime checks beyond basic pings. Combined with our new User Experience UI it also enables proactive problem detection.
This is a step by step example of how to set Synthetics up, as well as integrate it with APM. The application in this example, and instructions on how to instrument with APM it can be found in this blog.
Install Heartbeat
Download and install Heartbeat. Or if you prefer, pull and prepare the Docker image.
Create a monitor
Heartbeat uses monitors to pull data, so first we must create an http monitor and specify its check. This check is a basic login check to ensure our service’s authentication mechanism is working correctly. Note that the service_name
must be the same as the APM service name setting to ensure correlation between APM and Uptime. More details can be found here.
- type: http
id: synthetics-test
name: tutc-synth
service_name: todos-api
schedule: '@every 5s'
urls: ["http://frontend:8080/login"]
check.request:
method: POST
headers:
'Content-Type': 'application/json'
body:
'{"username":"test","password":"user"}'
check.response:
status: [200]
Start Heartbeat
In my case I used the below command, but yours might be different.
docker run -d --name=heartbeat --user=heartbeat --network=my_network --volume="$(pwd)/heartbeat.yml:/usr/share/heartbeat/heartbeat.yml:ro" docker.elastic.co/beats/heartbeat:7.10.0 --strict.perms=false -e
Check Uptime
Check the Uptime UI to see if your services are showing up.
Check APM Integration
Click on the down arrow at the end of the status monitor entry to navigate to the APM UI.
Create an Alert
We want to know if our authentication mechanism fails before customers start reporting login issues. Luckily we can create an alert directly from our Uptime UI.
Select Create alert
Select Monitor status alert
Give your alert a name, and be sure to specify which monitor the alert should be searching for
Specify an action for your alert, in this case we are using the index action.
Create the document to index and hit save.
Conclusion
Congratulations, you have just configured your first Synthetic monitor with Elastic Observability. If you want to try this out today, the fastest way is with a 14 day free trial of Elastic Cloud.