Observability as Code. Introductory.

The concept of Observability is centered on the continuous examination of a system and its dynamics over time. In this context, we focus on delving deeper into the system's inner workings, studying what goes into it and naturally its outputs.

We uphold a persistent feedback loop as we strive to comprehend and excel in managing the system.

In essence, Observability as code involves understanding the performance of your entire infrastructure system over time as a proactive measure to prevent downtime and unnecessary costs associated with potential issues.

Let's pause for a moment to revisit the concept of IaC before we move forward.

Infrastructure as Code

IaC offers a more efficient approach to provisioning cloud infrastructure programmatically. It replaces labor-intensive tasks and reduces the likelihood of errors by using code to configure, provision, update, and delete resources.

In technical terms, you can automate the management of various infrastructure components, including databases, storage, computing resources, networks, etc. by code.

IaC tools can be classified into 3 types

  1. Configuration Management Tools

  2. Server Templating Tools

  3. Provisioning Tools

Configuration Management Tools
As the name suggests, Configuration Management Tools are employed to keep the configuration of systems, including both computer hardware and software, in a specified state, aligning them with your desired settings. Examples of these tools include Ansible, Puppet, Salt Stack, and more.

Server Templating Tools
These tools are primarily employed to create customized images or instances of virtual machines or containers. These images include pre-installed software and dependencies. Once a container is deployed, it is intended to remain unaltered. Any necessary changes are implemented by updating the image and creating a new instance from it.

Provisioning Tool
Essentially, these tools assist in creating, destroying, and generally managing infrastructure components such as networks, databases, compute resources, and much more, using declarative, high-level code. Examples include Terraform (which we'll delve into), Pulumi, Ansible, and others.

Terraform

Terraform is a user-friendly high-level provisioning tool, as mentioned earlier. It employs the HashiCorp configuration language and can deploy infrastructure across various platforms, encompassing both private and public clouds by utilizing their respective Providers. Notably, Terraform is freely available and open-source, making it a versatile choice for infrastructure management.


resource "local_file" "students" {
        filename: "students-list",
        content: "Ali, Bola, Segun"
}

above is a simple terraform block cod that creates a resource name students with a local provider having a filename student-list.txt and contents of Ali, Bola & Segun.

Terraform works in three phases

  1. Init Phase: in this phase, terraform initiates the project and identifies the provider to be utilized for the specified environments.

  2. Plan phase: terraform drafts a plan to get to the target state

  3. Apply phase: terraform makes the necessary changes required on the target environment to bring it to the desired state.

    Now I believe we are all caught up with IaC, let's proceed into the world of observability.

Basically after deploying an infrastructure, you would want to know how it's doing. More like you are paying a close eye on your investments :). you can choose to observe on a service-by-service level or on a whole cloud level.

Let's jump to a hands-on approach.

1. the code below creates a data dog Azure integration for that of aws visit

resource "datadog_integration_azure" "sandbox" {
  tenant_name              = "<azure_tenant_name>"
  client_id                = "<azure_client_id>"
  client_secret            = "<azure_client_secret_key>"
  host_filters             = "examplefilter:true,example:true"
  app_service_plan_filters = "examplefilter:true,example:another"
  automute                 = true
  cspm_enabled             = true
  custom_metrics_enabled   = false
}
  1. Manages an application registration within Azure Active Directory.
resource "azuread_application" "example" {
  display_name     = "example"
  identifier_uris  = ["api://example-app"]
   template_id  = data.azuread_application_template.example.template_id
}