The Terraform Logz.io provider offers a great way to build integrations using Logz.io APIs.
Terraform is an infrastructure orchestrator written in Hashicorp Language (HCL). It is a popular Infrastructure-as-Code (IaC) tool that does away with manual configuration processes. You can take advantage of the Terraform Logz.io provider to really streamline the process of integrating observability into your dev workflows.
This guide assumes working knowledge of HashiCorp Terraform. If you're new to Terraform, we've got a great introduction if you're in for one. We also recommend the official Terraform guides and tutorials.
You can use the Terraform Logz.io Provider to manage users and log accounts in Logz.io, create and update log-based alerts and notification channels, and more.
The following Logz.io API endpoints are supported by this provider:
- User management
- Notification channels
- Log-based alerts
- Sub accounts
- Alerts(v2)
- Log shipping token
- Drop filters
- Archive logs
- Restore logs
- Authentication groups
- Kibana objects
- S3 Fetcher
- Grafana Dashboards
- Grafana folders
- Grafana Alert Rules
- Grafana Contact Point
- Grafana Notification Policy
- Metrics Accounts
Before you begin, you'll need:
To install this provider, copy and paste this code into your Terraform configuration:
terraform {
required_providers {
logzio = {
source = "logzio/logzio"
}
}
}
This will install the latest Logz.io provider.
If you wish to use a specific version of the provider, add under source
the field version
and specify your preferred version.
The provider accepts the following arguments:
-
api_token - (Required) The API token is used for authentication. Learn more.
-
region - (Defaults to null) The 2-letter region code identifies where your Logz.io account is hosted. Defaults to null for accounts hosted in the US East - Northern Virginia region. Learn more
You can pass the variables in a bash command for the arguments:
provider "logzio" {
api_token = var.api_token
region= var.your_api_region
}
Here's a great example demonstrating how easy it is to get up and running quickly with the Terraform Logz.io Provider.
This example adds a new Slack notification channel and creates a new alert in Kibana that will send notifications to the newly-created Slack channel.
The alert in this example will trigger whenever Logz.io records 10 loglevel:ERROR messages in 10 minutes.
terraform {
required_providers {
logzio = {
source = "logzio/logzio"
}
}
}
provider "logzio" {
api_token = "my-token"
region= "au"
}
resource "logzio_endpoint" "my_endpoint" {
title = "my_endpoint"
description = "my slack endpoint"
endpoint_type = "slack"
slack {
url = "${var.slack_url}"
}
}
resource "logzio_alert_v2" "my_alert" {
depends_on = [logzio_endpoint.my_endpoint]
title = "hello_there"
search_timeframe_minutes = 5
is_enabled = false
tags = ["some", "words"]
suppress_notifications_minutes = 5
alert_notification_endpoints = ["${logzio_endpoint.my_endpoint.id}"]
output_type = "JSON"
sub_components {
query_string = "loglevel:ERROR"
should_query_on_all_accounts = true
operation = "GREATER_THAN"
value_aggregation_type = "COUNT"
severity_threshold_tiers {
severity = "HIGH"
threshold = 10
}
severity_threshold_tiers {
severity = "INFO"
threshold = 5
}
}
}
This example will create a user in your Logz.io account.
terraform {
required_providers {
logzio = {
source = "logzio/logzio"
}
}
}
variable "api_token" {
type = "string"
description = "Your logzio API token"
}
variable "account_id" {
description = "The account ID where the new user will be created"
}
provider "logzio" {
api_token = var.api_token
region = var.region
}
resource "logzio_user" "my_user" {
username = "[email protected]"
fullname = "John Doe"
roles = [ 2 ]
account_id = var.account_id
}
Run the above plan using the following bash script:
export TF_LOG=DEBUG
terraform init
TF_VAR_api_token=${LOGZIO_API_TOKEN} TF_VAR_region=${LOGZIO_REGION} terraform plan -out terraform.plan
terraform apply terraform.plan
Before you run the script, update the arguments to match your details. See our examples for some complete working examples.
Found a bug or want to suggest a feature? Open an issue about it. Want to do it yourself? We are more than happy to accept external contributions from the community. Simply fork the repo, add your changes and open a PR.
You can import multiple sub-accounts as follows:
terraform import logzio_subaccount.my_subaccount <SUBACCOUNT-ID>
- v1.16.0:
- Upgrade
logzio_client_terraform
to1.22.0
. - Validate account existence before updating and set an empty account name If the name did not change to prevent API errors
- Upgrade
- v1.15.0:
- Upgrade
logzio_client_terraform
to1.21.0
. - Support Metrics Accounts API
- Upgrade
- v1.14.1:
- Upgrade
logzio_client_terraform
to1.20.1
.
- Upgrade
- v1.14.0:
- Upgrade
logzio_client_terraform
to1.20.0
. - Support Grafana folders.
- Support Grafana Alert Rules.
- Support Grafana Contact Point.
- Grafana Notification Policy.
- Upgrade
- v1.13.2:
- alerts v2:
- Bug fix: Add default value of
JSON
tooutput_type
to match API behaviour.
- Bug fix: Add default value of
- grafana dashboards:
- Bug fix: Handle dashboard configs with id and version fields.
- alerts v2:
Expand to check old versions
-
v1.13.1:
- s3 fetcher:
- Bug fix:
prefix
field now being applied.
- Bug fix:
- s3 fetcher:
-
v1.13.0:
- Upgrade
logzio_client_terraform
to1.16.0
. - Support Grafana Dashboards API.
- Upgrade
-
v1.12.0:
- Upgrade
logzio_client_terraform
to1.15.0
. - Support S3 Fetcher API.
- Upgrade
-
v1.11.0:
- Upgrade
terraform-plugin-sdk
tov2.24.1
. - Upgrade
logzio_client_terraform
to1.14.0
. alert_v2
- support alert scheduling.
- Upgrade
-
v1.10.2:
- Upgrade to logzio_client_terraform 1.13.1.
- Remove retries resources, as the new client handles it. Retries on update that validate update are still active.
-
v1.10.1:
- Upgrade to logzio_client_terraform 1.13.0.
- Bug fix for subaccount - field
reserved_daily_gb
can be 0.
-
v1.10.0
- Breaking Changes:
- Upgrading
terraform-plugin-sdk
tov2.21.0
:- Terraform 0.11 and lower will not be supported.
- To read more about migrating to v2 of the
terraform-plugin-sdk
see this article.
- Removal of the
logzio_alert
resource. Uselogzio_alert_v2
instead. logzio_user
:- Update resource
logzio_user
to match current API and repo code conventions - Removal of
roles
field. Use fieldrole
instead.
- Update resource
logzio_archive_logs
:- Removal of
s3_secret_credentials
. Useaws_access_key
andaws_secret_key
instead. See documentation for current configuration structure. - Removal of
archiveLogsAzureBlobStorageSettings
,archiveLogsAmazonS3StorageSettings
. Fields under these attributes are not nested anymore. See docs & examples for reference. - Renaming fields.
- Refactor code to match current API.
- datasource - removal of secret fields. See documentation for current available fields.
- Removal of
logzio_restore_logs
:- Add
username
field, to match current API.
- Add
logzio_subaccount
:- Removal of field
utilization_settings
.
- Removal of field
- Delete resource from state on unsuccessful read operation.
- Upgrading
- Upgrade to Go 1.18.
- Upgrade to logzio_client_terraform 1.12.0.
- Breaking Changes:
-
v1.9.2
- Bug fix: Fix diff for resource
alert_v2
in fieldsalert_notification_endpoints
,notification_emails
(#116).
- Bug fix: Fix diff for resource
-
v1.9.1
- Bug fix: plugin won't crash when import for
archive_logs
fails.
- Bug fix: plugin won't crash when import for
-
v1.9.0
- Update client version(v1.11.0).
- Support Kibana objects
-
v1.8.3
- Update client version(v1.10.3).
- Bug fixes:
- alerts_v2:
- Fix noisy diff for tags.
- Field
is_enabled
defaults totrue
.
- sub_accounts: allow creating flexible account without
max_daily_gb
.
- alerts_v2:
-
v1.8.2
- Update client version(v1.10.2).
- Bug fixes:
- alerts_v2: fix bug for columns requiring sort field.
- sub_accounts: add backoff for creating and updating sub accounts.
-
v1.8.1
- Upgrade provider's Go version from 1.15 to 1.16 in code and in release workflow.
- Improve tests - add sleep after each test.
-
v1.8.0
- Breaking change: custom endpoint - refactor Headers - now a string of comma-seperated key-value pairs.
- Update client version (v1.10.1) - bug fix for empty Header field.
- Add to custom endpoint datasource Description field.
-
v1.7.0
- Update client version (v1.10).
- Support authentication groups resource.
alerts_v2
: fix noisy diff forseverity_threshold_tiers
.
-
v1.6.1
- Update client version (v1.9.1) - bug fix for not found messages.
-
v1.6
- Update client version (v1.9).
- Support archive logs resource.
- Support restore logs resource.
-
v1.5
- Update client version(v1.8).
sub_account
:- Breaking changes:
- Deprecated attribute
utilization_settings
. Usefrequency_minutes
andutilization_enabled
instead.
- Deprecated attribute
- Added attributes
flexible
andreserved_daily_gb
. - Refactor tests.
- Refactor code to use Terraform's retry.
- Breaking changes:
endpoint
:- Breaking changes:
- Types naming.
- New endpoints for OpsGenie, ServiceNow and Microsoft Teams.
- Fix bug for
body_template
forcustom
type (#70). - Refactor tests.
- Refactor code to use Terraform's retry.
- Breaking changes:
alerts_v2
:- Fix bug for
filter_must
,filter_must_not
(#82) - Refactor tests.
- Refactor code to use Terraform's retry.
- Fix bug for
drop_filter
:- Improve tests.
-
v1.4
- Update client version(v1.7).
- Support Drop Filter resource.
-
v1.3
- Update client version(v1.6).
- Support Log Shipping Token resource.
-
v1.2.4
- Update client version(v1.5.3).
- Fix
sub account
to return attributesaccount_token
&account_id
.
-
v1.2.3
- Fix bug for
custom endpoint
empty headers. - Allow empty sharing accounts array in
sub account
. - Add retry in resource
sub account
. - Replace module
terraform
withterraform-plugin-sdk
. See further explanation here. - Upgrade to Go v1.15.
- Update client version(v1.5.2).
- Fix bug for
-
v1.2.2
- Update client version(v1.5.1).
- Fix alerts_v2 sort bug.
-
v1.2.1
- Fix alerts_v2 type "TABLE" bug.
-
v1.2
- Update client version(v1.5.0).
- Support Alerts v2 resource.
- Fix 404 error for Alerts.
-
v1.1.8
- Update client version
- Fix custom endpoint headers bug
-
v1.1.7
- Published to Terraform registry
-
v1.1.5
- Fix boolean parameters not parsed bug
- Support import command to state
-
v1.1.4
- Support Sub Accounts resource
- few bug fixes
- removed circleCI
-
v1.1.3
- examples now use TF12
- will now generate the meta data needed for the IntelliJ type IDE HCL plugin
- no more travis - just circle CI
- version bump to use the latest TF library (0.12.6), now compatible with TF12
-
1.1.2
- Moved some of the source code around to comply with TF provider layout convention
- Moved the examples into an examples directory
Terraform is a trademark of HashiCorp, Inc.