Monitoring as Code: How to implement better processes across your pipelines
Getting data from Continuous Integration (CI) and Continuous Deployment (CD) and then making it useful to the whole business in the same way has been more difficult. Using a Monitoring as Code approach can help. Find out what makes Monitoring as Code different.
Continuous Integration (CI) and Continuous Deployment (CD) have been with us for years. CI was first developed in 1991, while CD came into being in 2009, driven by rapidly evolving business requirements to increase velocity around development, testing and deployment. Over time, these processes became pipelines to manage how code was built, tested and deployed.
However, getting data from these processes and then making it useful to the whole business in the same way has been more difficult. Using a Monitoring as Code approach can help.
Why Monitoring as Code is needed
Today, CI/CD pipelines are an essential building block for developers to manage their processes ‘as Code.’ Using this approach, developers can apply the same approach and look for other software and business functions to optimise. Infrastructure as Code uses code to manage the assets and resources underneath the application, rather than traditional IT management tools and processes. Leveraging automation in this way means that you can use common software development approaches like versioning as part of your approach, and standardize the management and automation rules as standard in every application instance from the start.
This approach helps software developers deliver faster and more efficiently. Rather than islands of automation that are useful for specific teams, but then don’t integrate with each other, it applies automation to the whole business process around software development, deployment and management.
However, it can lead to operational concerns. For those companies that have not fully embraced the ‘Everything as Code’ approach, the developer team can automate and deliver more velocity in the software development process but it can then lead to problems if the IT infrastructure team does not take the same approach. Traditional infrastructure teams can easily fall behind if they don’t have the same ability to automate and manage production.
For Developers and DevOps teams, this can mean taking on the responsibility for the production instances as well. This “you build it, you support it” can be a challenge, particularly if you are not used to dealing with problems or issues in production. To bridge this gap, you will need data from your application components, cloud services and other infrastructure, and then organise that data so you can understand it over time. As part of this, you will want to automate the process as part of your overall approach.
Monitoring as Code is designed to fill this gap. Monitoring as Code provides insight into all the processes and changes that are taking place across the software delivery pipeline, and make that data available and useful for everyone involved. It covers the whole process, from build and test, through provisioning and testing, into production deployment and then ongoing observability.
What makes Monitoring as Code different?
It is important to differentiate between Monitoring as Code and using monitoring or observability tools on their own. While observability tools provide valuable data on everything from what is happening in a single application all the way up to tracking the whole software pipeline, they do not provide this as part of an automated system. Instead, they supply the data and leave the developers or DevOps team to organise that data and use it in context.
Monitoring as Code is different because it manages the whole end to end approach to how this data is collected, used and automatically processed. This can include making changes to deployments and components based on the monitoring results that are coming through.
It’s important to make it clear that this is not about using Infrastructure as Code for monitoring. While it is possible to automate some of the steps to gather data, using Infrastructure as Code for monitoring on its own only improves how those data sets are forwarded and handled. Monitoring as Code takes this further by looking at automated diagnosis, alerting and incident management, and even automated remediation.
Building Monitoring as Code
In order to implement Monitoring as Code, there are three elements to consider. The first is the tooling that developers have in place. Just like developers have a code pipeline to manage software development and deployment, they also need an observability pipeline that collects data and processes it. This observability pipeline takes data in, controls and changes that data, and then puts this data into multiple systems. These include standard alerting for developers around issues, but also cover storing data in systems of record, putting it into storage or analysis services, or processing it for automation.
This can be something that you put together yourself, or use products to cover specific areas of the pipeline. Whichever approach you choose, it should bring together cloud services, tools and products into a unified approach, with all the management and security features necessary too.
On top of the observability pipeline, end-to-end Monitoring as Code deployments should include the following components:
- Instrumentation. This covers the plugins and exporters used to collect data from application components and cloud services, as well as how those components are set up.
- Scheduling & orchestration. Once you have the instruments implemented, you will have to collect the data from them and manage how it is brought together.
- Diagnosis. This brings together additional sources for context, such as validating configuration and examining log files.
- Detection. This is where the evaluation, filtering, deduplication, and correlation of observability events takes place, based on rules put together as code.
- Notification. This covers the workflows for alerts and incident management, including automatically creating and resolving incidents based on code design.
- Processing. Once you have the data, metrics and events, it can be routed to data platforms like Elasticsearch, Splunk, InfluxDB, and TimescaleDB for storage and analysis.
- Automation. This is where you can put together your remediation steps, including integrations with runbook automation platforms like Ansible Tower, Rundeck, and Saltstack.
Once the implementation is in place, it is time to turn your processes into code. As an example, this would include how you think about your priorities and define them over time. When teams have multiple different tools in place to help them manage their work, getting consistency in place can be more difficult. Instead, looking at the overall pipeline can make it easier to bring all this data together and get a consistent workflow in place. Rather than trying to force every developer or team to adopt the same approach, this respects the work that has gone on in the past.
What gets standardised is how all the data gets handled as part of one process, rather than multiple different pipelines. Following this, it is time to codify your approaches into common templates. By creating these templates, you can simplify the process and include it as standard as code.
Once these codified templates have been created, you can then iterate on them as part of the workflow process. This can help you innovate and try new things, but more importantly bring everything in place as part of that overall workflow.
The most important element here is that you can take that tribal knowledge that exists within teams and turn it into things that can be repeated. Rather than relying on expertise or specific developers to carry out tasks, the code can be created and then shared for everyone to learn from. Rather than looking at who has to be involved based on their experience or seniority, Monitoring as Code can turn these processes into opportunities to discuss who can be involved across the team from the start, as most developers can use the code and learn from it. They can examine that code, modify it to meet their own requirements, and build on a common framework.
The future for Monitoring as Code
Monitoring as Code brings together all of your developers’ IT knowledge and builds it into a single declarative YAML file that automates diagnosis, management of alerts, and remediation of services. With developers already using CI/CD pipelines and automated infrastructure processes, you already have pipelines for versioning, building, testing, and deploying your software. It only makes sense that you would have your monitoring go through the same lifecycle.
By using Monitoring as Code to track code changes and new deployments, new metrics and failures can be followed automatically. However, this is not just something that should be useful for the software development team. Instead, Monitoring as Code should be viewed as an organisational initiative, covering both IT operations and business processes. As these processes can get turned into code, teams can achieve faster time to value out of any technology investment. Monitoring as Code is the key to building a unified view of the world, responding to that world automatically, and creating value for the whole organisation.