generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: add Logs Agent #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feat: add Logs Agent #368
Changes from 46 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
fbd3f13
feat: add log routing agent
0a9288c
fix: add log-routing-agent charts and remove tflint error
64da445
Merge branch 'main' into 9800-lr
iamar7 33d88c8
fix: update pr_test
e246104
fix: update permission
98258f8
Merge branch 'main' into 9800-lr
iamar7 0be893f
fix: added log routing selected log source path
b15c02a
Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
2fce492
update common-dev-assets
2e9c129
fix: added support for sending logs directly to ICL
c16039b
fix: pre-commit issues
f623416
remove common dev
9917642
update common dev
86d1b5a
Merge branch 'main' of https://github.com/terraform-ibm-modules/terra…
c414473
Merge branch 'main' into 9800-lr
iamar7 390c295
fix: update helm chart
863dc86
Merge branch '9800-lr' of https://github.com/terraform-ibm-modules/te…
0abe150
fix: pre-commit issues
f04d4bb
empty commit
2f676be
skipping other tests
85fa6ee
use logs-agent helm chart
Aashiq-J 1a2cb38
precommit
Aashiq-J 2ebfcf1
remove helm charts
Aashiq-J 82c6b22
revert skip
Aashiq-J 412ddd2
update scc
Aashiq-J ea98fb5
few review changes
Aashiq-J 3db545f
review changes
Aashiq-J 8f56d30
update module
91ae59e
remove common dev
f67699f
fix: resolve review comments
4760266
fix: resolve comments
93ff8b3
fix: upgrade terraform version
6c5cd31
fix: resolve comments
a20999c
Merge branch 'main' into 9800-lr
iamar7 d852aae
review changes
Aashiq-J d484fe7
precommit changes
Aashiq-J ab66224
fixes
Aashiq-J a815564
update variable description
Aashiq-J ec318b9
skip for this version
Aashiq-J bbbb480
wait till IngressReady
Aashiq-J f18d20e
update provider
Aashiq-J e33e8fc
test
Aashiq-J 6e5a433
increase time
Aashiq-J ff34453
add cert
Aashiq-J fbd8024
update version
Aashiq-J 195f954
test
Aashiq-J 3a2f08e
Merge branch 'main' into 9800-lr
Aashiq-J ece3a59
test
Aashiq-J 259367c
cleanup
ocofaigh 48b3bbd
address cra
ocofaigh 2f84a7f
baseline update
ocofaigh c8e81ea
SKIP UPGRADE TEST
ocofaigh 964549d
fix
ocofaigh 89011f0
test: ignore update
ocofaigh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| # Deploy basic observability agents | ||
| # Log Analysis agent | ||
|
|
||
| ## Deprecated: Log Analysis | ||
|
|
||
| **Important:** IBM Log Analysis will be discontinued on 30 March 2025 and replaced by IBM Cloud Logs. | ||
|
|
||
| An end-to-end example that uses the module's default variable values. | ||
|
|
||
| The example sets up the logging agent for [Kubernetes metadata filtering](https://github.com/logdna/logdna-agent-v2/blob/3.8/docs/KUBERNETES.md#configuration-for-kubernetes-metadata-filtering). | ||
|
|
||
| The example configures the agent to include all log lines coming from the `default` Kubernetes namespace and excludes anything with a label `app.kubernetes.io/name` and value `sample-app` or an annotation `annotation.user` with the value `sample-user`. | ||
|
|
||
| :exclamation: The service IBM Cloud Log Analysis is now deprecated and new instances cannot be provisioned after November 30, 2024, and all existing instances will be destroyed on March 30, 2025. For more information, see https://cloud.ibm.com/docs/log-analysis?topic=log-analysis-getting-started |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Monitoring agent + Cloud Logs agent on Kubernetes using CSE ingress endpoint with an apikey | ||
|
|
||
| An example that shows how to deploy Logs Routing agents and Monitoring agent in a Kubernetes cluster to send Logs directly to IBM Cloud Logs and Cloud Monitoring instance respectively. | ||
|
|
||
| The example provisions the following resources: | ||
| - A new resource group, if an existing one is not passed in. | ||
| - A basic VPC. | ||
| - A Kubernetes cluster. | ||
| - A Service ID with `Sender` role to `logs` service. | ||
| - An IBM Cloud Logs and Cloud Monitoring instance | ||
| - Logs agents and Monitoring agent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| ############################################################################## | ||
| # Resource Group | ||
| ############################################################################## | ||
|
|
||
| module "resource_group" { | ||
| source = "git::https://github.com/terraform-ibm-modules/terraform-ibm-resource-group.git?ref=v1.1.6" | ||
| # if an existing resource group is not set (null) create a new one using prefix | ||
| resource_group_name = var.resource_group == null ? "${var.prefix}-resource-group" : null | ||
| existing_resource_group_name = var.resource_group | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # Trusted Profile | ||
| ############################################################################## | ||
|
|
||
| locals { | ||
| logs_agent_namespace = "ibm-observe" | ||
| logs_agent_name = "logs-agent" | ||
| } | ||
|
|
||
| # As a `Sender`, you can send logs to your IBM Cloud Logs service instance - but not query or tail logs. This role is meant to be used by agents and routers sending logs. | ||
| module "iam_service_id" { | ||
| source = "terraform-ibm-modules/iam-service-id/ibm" | ||
| version = "1.2.0" | ||
| iam_service_id_name = "${var.prefix}-service-id" | ||
| iam_service_id_description = "Logs Agent service id" | ||
| iam_service_id_apikey_provision = true | ||
| iam_service_policies = { | ||
| logs = { | ||
| roles = ["Sender"] | ||
| resources = [{ | ||
| service = "logs" | ||
| }] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # Create VPC and IKS Cluster | ||
| ############################################################################## | ||
|
|
||
| resource "ibm_is_vpc" "example_vpc" { | ||
| name = "${var.prefix}-vpc" | ||
| resource_group = module.resource_group.resource_group_id | ||
| tags = var.resource_tags | ||
| } | ||
|
|
||
| resource "ibm_is_subnet" "testacc_subnet" { | ||
| name = "${var.prefix}-subnet" | ||
| vpc = ibm_is_vpc.example_vpc.id | ||
| zone = "${var.region}-1" | ||
| total_ipv4_address_count = 256 | ||
| resource_group = module.resource_group.resource_group_id | ||
| } | ||
|
|
||
| # Lookup the current default kube version | ||
| data "ibm_container_cluster_versions" "cluster_versions" {} | ||
| locals { | ||
| default_version = data.ibm_container_cluster_versions.cluster_versions.default_kube_version | ||
| } | ||
|
|
||
| resource "ibm_container_vpc_cluster" "cluster" { | ||
| name = var.prefix | ||
| vpc_id = ibm_is_vpc.example_vpc.id | ||
| kube_version = local.default_version | ||
| flavor = "bx2.4x16" | ||
| worker_count = "2" | ||
| force_delete_storage = true | ||
| wait_till = "IngressReady" | ||
| zones { | ||
| subnet_id = ibm_is_subnet.testacc_subnet.id | ||
| name = "${var.region}-1" | ||
| } | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| tags = var.resource_tags | ||
| } | ||
|
|
||
| data "ibm_container_cluster_config" "cluster_config" { | ||
| cluster_name_id = ibm_container_vpc_cluster.cluster.id | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| } | ||
|
|
||
| # Sleep to allow RBAC sync on cluster | ||
| resource "time_sleep" "wait_operators" { | ||
| depends_on = [data.ibm_container_cluster_config.cluster_config] | ||
| create_duration = "45s" | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # Observability Instance | ||
| ############################################################################## | ||
|
|
||
|
|
||
| module "observability_instances" { | ||
| source = "terraform-ibm-modules/observability-instances/ibm" | ||
| version = "2.18.1" | ||
| providers = { | ||
| logdna.at = logdna.at | ||
| logdna.ld = logdna.ld | ||
| } | ||
| resource_group_id = module.resource_group.resource_group_id | ||
| region = var.region | ||
| cloud_logs_plan = "standard" | ||
| cloud_monitoring_plan = "graduated-tier" | ||
| activity_tracker_provision = false | ||
| enable_platform_logs = false | ||
| enable_platform_metrics = false | ||
| log_analysis_provision = false | ||
| cloud_logs_instance_name = "${var.prefix}-cloud-logs" | ||
| cloud_monitoring_instance_name = "${var.prefix}-cloud-monitoring" | ||
| } | ||
|
|
||
| ############################################################################## | ||
| # Observability Agents | ||
| ############################################################################## | ||
|
|
||
| module "observability_agents" { | ||
| source = "../../modules/logs-agent-module" | ||
| depends_on = [time_sleep.wait_operators] | ||
| cluster_id = ibm_container_vpc_cluster.cluster.id | ||
| cluster_resource_group_id = module.resource_group.resource_group_id | ||
| # Logs Agent | ||
| # logs_agent_enabled = true | ||
| logs_agent_iam_mode = "IAMAPIKey" | ||
| logs_agent_iam_api_key = module.iam_service_id.service_id_apikey | ||
| logs_agent_namespace = local.logs_agent_namespace | ||
| logs_agent_name = local.logs_agent_name | ||
| cloud_logs_ingress_endpoint = module.observability_instances.cloud_logs_ingress_private_endpoint | ||
| cloud_logs_ingress_port = 3443 | ||
| logs_agent_enable_scc = false | ||
| # # Monitoring agent | ||
| # cloud_monitoring_enabled = true | ||
| # cloud_monitoring_access_key = module.observability_instances.cloud_monitoring_access_key | ||
| # cloud_monitoring_instance_region = module.observability_instances.region | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ############################################################################## | ||
| # Outputs | ||
| ############################################################################## | ||
|
|
||
| #output "myoutput" { | ||
| # description = "Description of my output" | ||
| # value = "value" | ||
| # depends_on = [<some resource>] | ||
| #} | ||
|
|
||
| ############################################################################## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| provider "ibm" { | ||
| ibmcloud_api_key = var.ibmcloud_api_key | ||
| region = var.region | ||
| } | ||
|
|
||
| provider "helm" { | ||
| kubernetes { | ||
| host = data.ibm_container_cluster_config.cluster_config.host | ||
| token = data.ibm_container_cluster_config.cluster_config.token | ||
| cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate | ||
| } | ||
| } | ||
|
|
||
| provider "kubernetes" { | ||
| host = data.ibm_container_cluster_config.cluster_config.host | ||
| token = data.ibm_container_cluster_config.cluster_config.token | ||
| cluster_ca_certificate = data.ibm_container_cluster_config.cluster_config.ca_certificate | ||
| } | ||
|
|
||
| locals { | ||
| at_endpoint = "https://api.${var.region}.logging.cloud.ibm.com" | ||
| } | ||
|
|
||
| provider "logdna" { | ||
| alias = "at" | ||
| servicekey = module.observability_instances.activity_tracker_resource_key != null ? module.observability_instances.activity_tracker_resource_key : "" | ||
| url = local.at_endpoint | ||
| } | ||
|
|
||
| provider "logdna" { | ||
| alias = "ld" | ||
| servicekey = module.observability_instances.log_analysis_resource_key != null ? module.observability_instances.log_analysis_resource_key : "" | ||
| url = local.at_endpoint | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use same format / terminology as https://github.com/terraform-ibm-modules/terraform-ibm-observability-instances/blob/main/README.md ?
So maybe go with:
Important
The IBM Log Analysis service is deprecated. IBM Cloud Logs is the replacement service and is now the agent that is deployed by this module.