-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introducing agent module (#319)
* feat: introducing elk agent module * feat: Updated README.md * feat: Updated agent yal with es_host * fix --------- Co-authored-by: Jacopo <[email protected]>
- Loading branch information
1 parent
6bc45a2
commit 15bbe5e
Showing
13 changed files
with
3,774 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,44 @@ | ||
# Elastic Stack | ||
|
||
This module allow the creation of Elastic Stack | ||
|
||
## Configurations | ||
|
||
## How to use it | ||
|
||
TODO | ||
|
||
<!-- markdownlint-disable --> | ||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | | ||
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | ~>3.30 | | ||
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | ~> 2.0 | | ||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | ~> 2.27 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [kubernetes_manifest.elastic_agent](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/manifest) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|---------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|----------------|--------------------|:--------:| | ||
| <a name="input_es_host"></a> [es\_host](#input\_es\_host) | Elastic Host | `string` | n/a | yes | | ||
| <a name="input_dedicated_log_instance_name"></a> [dedicated\_log\_instance\_name](#input\_dedicated\_log\_instance\_name) | n/a | `list(string)` | n/a | yes | | ||
| <a name="input_eck_version"></a> [eck\_version](#input\_eck\_version) | ECK (Elastic Cloud on Kubernetes) version, see: https://www.elastic.co/guide/en/cloud-on-k8s/index.html for futher versions | `string` | n/a | yes | | ||
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace for ECK Operator | `string` | `"elastic-system"` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
6 changes: 6 additions & 0 deletions
6
elastic_agent/logs-generic/component_logs-generic-mappings.json
This file contains 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,6 @@ | ||
{ | ||
"template":{}, | ||
"_meta": { | ||
"description": "Mappings for generic" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
elastic_agent/logs-generic/component_logs-generic-settings.json
This file contains 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,10 @@ | ||
{ | ||
"template":{ | ||
"settings": { | ||
"index.lifecycle.name": "logs-generic" | ||
} | ||
}, | ||
"_meta": { | ||
"description": "Settings for generic" | ||
} | ||
} |
This file contains 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,8 @@ | ||
{ | ||
"data_view": { | ||
"title": "logs-generic-*", | ||
"name": "Generic log Data View", | ||
"timeFieldName": "@timestamp" | ||
}, | ||
"override": true | ||
} |
This file contains 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,40 @@ | ||
{ | ||
"policy": { | ||
"phases": { | ||
"hot": { | ||
"min_age": "0ms", | ||
"actions": { | ||
"rollover": { | ||
"max_primary_shard_size": "50gb", | ||
"max_age": "2d" | ||
} | ||
} | ||
}, | ||
"warm": { | ||
"min_age": "2d", | ||
"actions": { | ||
"set_priority": { | ||
"priority": 50 | ||
} | ||
} | ||
}, | ||
"cold": { | ||
"min_age": "4d", | ||
"actions": { | ||
"set_priority": { | ||
"priority": 0 | ||
} | ||
} | ||
}, | ||
"delete": { | ||
"min_age": "7d", | ||
"actions": { | ||
"delete": {} | ||
} | ||
} | ||
}, | ||
"_meta": { | ||
"description": "Policy for generic" | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
elastic_agent/logs-generic/index_template_logs-generic.json
This file contains 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 @@ | ||
{ | ||
"index_patterns": [ | ||
"logs-generic-*" | ||
], | ||
"data_stream": {}, | ||
"composed_of": [ "logs-generic-mappings", "logs-generic-settings" ], | ||
"priority": 500, | ||
"_meta": { | ||
"description": "Index template for generic" | ||
} | ||
} |
This file contains 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,66 @@ | ||
locals { | ||
|
||
# | ||
# Other | ||
# | ||
logs_general_to_exclude_paths = distinct(flatten([ | ||
for instance_name in var.dedicated_log_instance_name : "'/var/log/containers/${instance_name}-*.log'" | ||
])) | ||
|
||
#https://raw.githubusercontent.com/elastic/elastic-agent/8.9/deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml | ||
agent_yaml = templatefile("${path.module}/yaml/${var.eck_version}/agent.yaml", { | ||
|
||
es_host = var.es_host | ||
namespace = var.namespace | ||
dedicated_log_instance_name = var.dedicated_log_instance_name | ||
logs_general_to_exclude_paths = local.logs_general_to_exclude_paths | ||
|
||
system_name = "system-1" | ||
system_id = "id_system_1" | ||
system_revision = 1 | ||
|
||
kubernetes_name = "kubernetes-1" | ||
kubernetes_id = "id_kubernetes_1" | ||
kubernetes_revision = 1 | ||
|
||
apm_name = "apm-1" | ||
apm_id = "id_apm_1" | ||
apm_revision = 1 | ||
}) | ||
|
||
} | ||
|
||
|
||
############# | ||
# Install Elastic Agent | ||
############# | ||
#data "kubectl_file_documents" "elastic_agent" { | ||
# content = local.agent_yaml | ||
#} | ||
locals { | ||
elastic_agent_defaultMode_converted = { | ||
for value in [ | ||
for yaml in split( | ||
"\n---\n", | ||
"\n${replace(local.agent_yaml, "/(?m)^---[[:blank:]]*(#.*)?$/", "---")}\n" | ||
) : | ||
yamldecode(replace(replace(yaml, "/(?s:\nstatus:.*)$/", ""), "0640", "416")) #transform 'defaultMode' octal value (0640) to decimal value (416) | ||
if trimspace(replace(yaml, "/(?m)(^[[:blank:]]*(#.*)?$)+/", "")) != "" | ||
] : "${value["kind"]}--${value["metadata"]["name"]}" => value | ||
} | ||
} | ||
# output "test" { | ||
# value = local.elastic_agent_defaultMode_converted | ||
# } | ||
|
||
resource "kubernetes_manifest" "elastic_agent" { | ||
|
||
for_each = local.elastic_agent_defaultMode_converted | ||
|
||
manifest = each.value | ||
|
||
field_manager { | ||
force_conflicts = true | ||
} | ||
computed_fields = ["spec.template.spec.containers[0].resources"] | ||
} |
Empty file.
This file contains 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,23 @@ | ||
variable "es_host" { | ||
description = "Elastic Host" | ||
type = string | ||
} | ||
|
||
variable "namespace" { | ||
description = "Namespace for ECK Operator" | ||
type = string | ||
default = "elastic-system" | ||
} | ||
|
||
variable "dedicated_log_instance_name" { | ||
type = list(string) | ||
} | ||
|
||
variable "eck_version" { | ||
type = string | ||
description = "ECK (Elastic Cloud on Kubernetes) version, see: https://www.elastic.co/guide/en/cloud-on-k8s/index.html for futher versions" | ||
validation { | ||
condition = contains(["2.12", "2.9", "2.6"], var.eck_version) | ||
error_message = "The ECK version supported is only 2.9 or 2.6" | ||
} | ||
} |
This file contains 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,19 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "~>3.30" | ||
} | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = "~> 2.27" | ||
} | ||
|
||
kubectl = { | ||
source = "alekc/kubectl" | ||
version = "~> 2.0" | ||
} | ||
} | ||
} |
Oops, something went wrong.