Skip to content

Instantly share code, notes, and snippets.

@sgsharma
Last active November 28, 2023 20:45
Show Gist options
  • Save sgsharma/2aefa08084614f579851f46a27df9809 to your computer and use it in GitHub Desktop.
Save sgsharma/2aefa08084614f579851f46a27df9809 to your computer and use it in GitHub Desktop.
ec2_metrics_board

Prerequisites

You must have terraform installed. Follow these directions to install for your platform.

You will need a Honeycomb API key with the adequate permissions to create boards, queries etc.. Once you have the API key, you can set it like so:

export HONEYCOMB_API_KEY=<YOUR_API_KEY>

Or define it via the api_key variable.

Quickstart

Create a honeycomb.tfvars file with the following variables:

dataset = "<YOUR-METRICS-DATASET>"

Then, to run terraform plan or apply for all modules in this directory (terraform), run:

terraform init
terraform plan --var-file="honeycomb.tfvars" -out tfplan.out
terraform apply --var-file="honeycomb.tfvars"
data "honeycombio_query_specification" "system_filesystem_usage_free" {
time_range = 86400
breakdowns = ["host.name"]
calculation {
op = "RATE_AVG"
column = "system.filesystem.usage.free"
}
order {
column = "system.filesystem.usage.free"
op = "RATE_AVG"
order = "descending"
}
}
resource "honeycombio_query" "system_filesystem_usage_free" {
dataset = var.dataset
query_json = data.honeycombio_query_specification.system_filesystem_usage_free.json
}
resource "honeycombio_query_annotation" "system_filesystem_usage_free" {
dataset = var.dataset
query_id = honeycombio_query.system_filesystem_usage_free.id
name = "System Filesystem Usage Free"
description = "A breakdown of the free space on each host"
}
resource "honeycombio_board" "overview" {
name = "EC2 metrics by host"
query {
caption = "System Filesystem Usage Free"
query_id = honeycombio_query.system_filesystem_usage_free.id
query_annotation_id = honeycombio_query_annotation.system_filesystem_usage_free.id
graph_settings {
utc_xaxis = true
}
}
}
dataset = "__all__"
# Terraform configuration
terraform {
required_providers {
honeycombio = {
source = "honeycombio/honeycombio"
version = "0.20.1"
}
}
}
provider "honeycombio" {
# You can set the API key with the environment variable HONEYCOMBIO_APIKEY
}
variable "dataset" {
description = "Dataset to use"
type = string
default = "ExampleMetricsDataset"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment