From 14172bd50558989a1335432a26fc8a3c84e35de4 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 11:53:04 +0200 Subject: [PATCH 01/14] Add Kubernetes deploy events - Add `logzio-k8s-events` sub chart version `0.0.2`: - Sends Kubernetes deploy events logs. --- config-templates/helm.json | 17 +++++++++++++++++ configs/2-1-k8s-eks.json | 25 +++++++++++++++++++++++++ configs/2-2-k8s-aks.json | 27 ++++++++++++++++++++++++++- configs/2-3-k8s-gke.json | 27 ++++++++++++++++++++++++++- configs/2-4-k8s-digitalocean.json | 27 ++++++++++++++++++++++++++- 5 files changed, 120 insertions(+), 3 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index 9bbb2ceec..8b707fe05 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -121,5 +121,22 @@ } ] }, + { + "template": " --set deployEvents.enabled=true \\", + "targetElement": "datasources[?(@.name=='DeployEvents')]", + "conditionalTemplates": [ + { + "template": " --set logzio-k8s-events.env_id='{{value}}' \\", + "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", + "keepAsPlaceholder": true + }, + { + "template": " --set logzio-k8s-events.secrets.logzioShippingToken='<>' \\" + }, + { + "template": " --set logzio-k8s-events.secrets.logzioListener='<>' \\" + } + ] + }, { "template": "logzio-monitoring logzio-helm/logzio-monitoring" } ] diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index 2ec977ef8..00d1d9e77 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -114,6 +114,31 @@ "params": [] } ] + }, + { + "name": "Deploy Events", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "label": "DeployEvents", + "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", + "params": [ + { + "type": "text", + "name": "envID", + "label": "Environment Name", + "description": "The name for your environments identifier, to easily identify the telemetry data for each environment.", + "hint": "By typing an environment name, the name will be added as a label to the telemetry data of your environment.", + "value": "", + "pattern": "^[a-zA-Z0-9_-]*$", + "patternError": "Only letters, numbers, dashes and underscores are allowed" + } + ], + "telemetries": [ + { + "type": "LOG_ANALYTICS", + "hint": "Switch the toggle on if you want Logz.io Telemetry Collector to collect deploy events from your Kubernetes cluster components.", + "params": [] + } + ] } ] } diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index 0f2dc649e..bc3ac7a90 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -108,7 +108,32 @@ "params": [] } ] - } + }, + { + "name": "Deploy Events", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "label": "DeployEvents", + "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", + "params": [ + { + "type": "text", + "name": "envID", + "label": "Environment Name", + "description": "The name for your environments identifier, to easily identify the telemetry data for each environment.", + "hint": "By typing an environment name, the name will be added as a label to the telemetry data of your environment.", + "value": "", + "pattern": "^[a-zA-Z0-9_-]*$", + "patternError": "Only letters, numbers, dashes and underscores are allowed" + } + ], + "telemetries": [ + { + "type": "LOG_ANALYTICS", + "hint": "Switch the toggle on if you want Logz.io Telemetry Collector to collect deploy events from your Kubernetes cluster components.", + "params": [] + } + ] + } ] } ] diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index fe97c30a2..44da3d094 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -106,7 +106,32 @@ "params": [] } ] - } + }, + { + "name": "Deploy Events", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "label": "DeployEvents", + "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", + "params": [ + { + "type": "text", + "name": "envID", + "label": "Environment Name", + "description": "The name for your environments identifier, to easily identify the telemetry data for each environment.", + "hint": "By typing an environment name, the name will be added as a label to the telemetry data of your environment.", + "value": "", + "pattern": "^[a-zA-Z0-9_-]*$", + "patternError": "Only letters, numbers, dashes and underscores are allowed" + } + ], + "telemetries": [ + { + "type": "LOG_ANALYTICS", + "hint": "Switch the toggle on if you want Logz.io Telemetry Collector to collect deploy events from your Kubernetes cluster components.", + "params": [] + } + ] + } ] } ] diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index 2c4f3b82b..007ec33b7 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -106,7 +106,32 @@ "params": [] } ] - } + }, + { + "name": "Deploy Events", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "label": "DeployEvents", + "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", + "params": [ + { + "type": "text", + "name": "envID", + "label": "Environment Name", + "description": "The name for your environments identifier, to easily identify the telemetry data for each environment.", + "hint": "By typing an environment name, the name will be added as a label to the telemetry data of your environment.", + "value": "", + "pattern": "^[a-zA-Z0-9_-]*$", + "patternError": "Only letters, numbers, dashes and underscores are allowed" + } + ], + "telemetries": [ + { + "type": "LOG_ANALYTICS", + "hint": "Switch the toggle on if you want Logz.io Telemetry Collector to collect deploy events from your Kubernetes cluster components.", + "params": [] + } + ] + } ] } ] From 6db2d88102b2622e471612966827db2dd3e1c7e7 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 13:36:34 +0200 Subject: [PATCH 02/14] Update label name with space --- config-templates/helm.json | 4 ++-- configs/2-1-k8s-eks.json | 2 +- configs/2-2-k8s-aks.json | 2 +- configs/2-3-k8s-gke.json | 2 +- configs/2-4-k8s-digitalocean.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index 8b707fe05..ab5168685 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='DeployEvents')]", + "targetElement": "datasources[?(@.name=='Deploy Events')]", "conditionalTemplates": [ { "template": " --set logzio-k8s-events.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", + "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index 00d1d9e77..4eb4f9f04 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -118,7 +118,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index bc3ac7a90..923f3a453 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -112,7 +112,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 44da3d094..384f882d2 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index 007ec33b7..f0d7924b6 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { From e13593ce8c9d640726fa59f2bed54fa05205bedc Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 15:56:05 +0200 Subject: [PATCH 03/14] Revert "Update label name with space" This reverts commit 6db2d88102b2622e471612966827db2dd3e1c7e7. --- config-templates/helm.json | 4 ++-- configs/2-1-k8s-eks.json | 2 +- configs/2-2-k8s-aks.json | 2 +- configs/2-3-k8s-gke.json | 2 +- configs/2-4-k8s-digitalocean.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index ab5168685..8b707fe05 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='Deploy Events')]", + "targetElement": "datasources[?(@.name=='DeployEvents')]", "conditionalTemplates": [ { "template": " --set logzio-k8s-events.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", + "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index 4eb4f9f04..00d1d9e77 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -118,7 +118,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "Deploy Events", + "label": "DeployEvents", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index 923f3a453..bc3ac7a90 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -112,7 +112,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "Deploy Events", + "label": "DeployEvents", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 384f882d2..44da3d094 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "Deploy Events", + "label": "DeployEvents", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index f0d7924b6..007ec33b7 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "Deploy Events", + "label": "DeployEvents", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { From e4ed890064c4d17f0b436c14865e5c0062aad203 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 16:04:35 +0200 Subject: [PATCH 04/14] Revert "Revert "Update label name with space"" This reverts commit e13593ce8c9d640726fa59f2bed54fa05205bedc. --- config-templates/helm.json | 4 ++-- configs/2-1-k8s-eks.json | 2 +- configs/2-2-k8s-aks.json | 2 +- configs/2-3-k8s-gke.json | 2 +- configs/2-4-k8s-digitalocean.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index 8b707fe05..ab5168685 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='DeployEvents')]", + "targetElement": "datasources[?(@.name=='Deploy Events')]", "conditionalTemplates": [ { "template": " --set logzio-k8s-events.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", + "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index 00d1d9e77..4eb4f9f04 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -118,7 +118,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index bc3ac7a90..923f3a453 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -112,7 +112,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 44da3d094..384f882d2 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index 007ec33b7..f0d7924b6 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -110,7 +110,7 @@ { "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", - "label": "DeployEvents", + "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ { From 3823c7868a49f662c286490f416f83adb0637ea1 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 16:47:19 +0200 Subject: [PATCH 05/14] Update datasource name --- config-templates/helm.json | 4 ++-- configs/2-3-k8s-gke.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index ab5168685..8b707fe05 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='Deploy Events')]", + "targetElement": "datasources[?(@.name=='DeployEvents')]", "conditionalTemplates": [ { "template": " --set logzio-k8s-events.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", + "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 384f882d2..bae00bc24 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -108,7 +108,7 @@ ] }, { - "name": "Deploy Events", + "name": "DeployEvents", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", From 010264b9110e77360bf38f8636d20313a1959daf Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 17:46:22 +0200 Subject: [PATCH 06/14] Add deploy events agent scripts - Added deploy events datasource scripts per platform and sub type. - Gets token, listener, env_id from agent. - Checks which options were chose. --- .../aks/deployevents/installer/functions.bash | 83 +++++++ .../aks/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../aks/deployevents/telemetry/logs/logs.bash | 27 ++ .../deployevents/installer/functions.bash | 83 +++++++ .../deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../deployevents/telemetry/logs/logs.bash | 27 ++ .../eks/deployevents/installer/functions.bash | 86 +++++++ .../eks/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../eks/deployevents/telemetry/logs/logs.bash | 27 ++ .../gke/deployevents/installer/functions.bash | 86 +++++++ .../gke/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../gke/deployevents/telemetry/logs/logs.bash | 27 ++ .../aks/deployevents/installer/functions.bash | 83 +++++++ .../aks/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../aks/deployevents/telemetry/logs/logs.bash | 27 ++ .../deployevents/installer/functions.bash | 83 +++++++ .../deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../deployevents/telemetry/logs/logs.bash | 27 ++ .../eks/deployevents/installer/functions.bash | 86 +++++++ .../eks/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../eks/deployevents/telemetry/logs/logs.bash | 27 ++ .../gke/deployevents/installer/functions.bash | 86 +++++++ .../gke/deployevents/installer/installer.bash | 30 +++ .../deployevents/prerequisites/functions.bash | 5 + .../prerequisites/prerequisites.bash | 5 + .../telemetry/logs/functions.bash | 42 ++++ .../gke/deployevents/telemetry/logs/logs.bash | 27 ++ .../aks/deployevents/installer/functions.ps1 | 229 +++++++++++++++++ .../aks/deployevents/installer/installer.ps1 | 55 +++++ .../deployevents/prerequisites/functions.ps1 | 3 + .../prerequisites/prerequisites.ps1 | 6 + .../deployevents/telemetry/logs/functions.ps1 | 182 ++++++++++++++ .../aks/deployevents/telemetry/logs/logs.ps1 | 27 ++ .../deployevents/installer/functions.ps1 | 229 +++++++++++++++++ .../deployevents/installer/installer.ps1 | 55 +++++ .../deployevents/prerequisites/functions.ps1 | 3 + .../prerequisites/prerequisites.ps1 | 6 + .../deployevents/telemetry/logs/functions.ps1 | 182 ++++++++++++++ .../deployevents/telemetry/logs/logs.ps1 | 27 ++ .../eks/deployevents/installer/functions.ps1 | 231 ++++++++++++++++++ .../eks/deployevents/installer/installer.ps1 | 55 +++++ .../deployevents/prerequisites/functions.ps1 | 3 + .../prerequisites/prerequisites.ps1 | 6 + .../deployevents/telemetry/logs/functions.ps1 | 182 ++++++++++++++ .../eks/deployevents/telemetry/logs/logs.ps1 | 27 ++ .../gke/deployevents/installer/functions.ps1 | 231 ++++++++++++++++++ .../gke/deployevents/installer/installer.ps1 | 55 +++++ .../deployevents/prerequisites/functions.ps1 | 3 + .../prerequisites/prerequisites.ps1 | 6 + .../deployevents/telemetry/logs/functions.ps1 | 182 ++++++++++++++ .../gke/deployevents/telemetry/logs/logs.ps1 | 27 ++ .../k8s/datasource_logs_utils.bash | 92 +++++++ resources-mac/k8s/datasource_logs_utils.bash | 92 +++++++ 74 files changed, 3744 insertions(+) create mode 100755 datasources/linux/kubernetes/aks/deployevents/installer/functions.bash create mode 100755 datasources/linux/kubernetes/aks/deployevents/installer/installer.bash create mode 100755 datasources/linux/kubernetes/aks/deployevents/prerequisites/functions.bash create mode 100644 datasources/linux/kubernetes/aks/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/linux/kubernetes/aks/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/linux/kubernetes/aks/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/linux/kubernetes/digitalocean/deployevents/installer/functions.bash create mode 100755 datasources/linux/kubernetes/digitalocean/deployevents/installer/installer.bash create mode 100755 datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/functions.bash create mode 100644 datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/linux/kubernetes/eks/deployevents/installer/functions.bash create mode 100755 datasources/linux/kubernetes/eks/deployevents/installer/installer.bash create mode 100755 datasources/linux/kubernetes/eks/deployevents/prerequisites/functions.bash create mode 100644 datasources/linux/kubernetes/eks/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/linux/kubernetes/eks/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/linux/kubernetes/eks/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/linux/kubernetes/gke/deployevents/installer/functions.bash create mode 100755 datasources/linux/kubernetes/gke/deployevents/installer/installer.bash create mode 100755 datasources/linux/kubernetes/gke/deployevents/prerequisites/functions.bash create mode 100644 datasources/linux/kubernetes/gke/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/linux/kubernetes/gke/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/linux/kubernetes/gke/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/mac/kubernetes/aks/deployevents/installer/functions.bash create mode 100755 datasources/mac/kubernetes/aks/deployevents/installer/installer.bash create mode 100755 datasources/mac/kubernetes/aks/deployevents/prerequisites/functions.bash create mode 100644 datasources/mac/kubernetes/aks/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/mac/kubernetes/aks/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/mac/kubernetes/aks/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/mac/kubernetes/digitalocean/deployevents/installer/functions.bash create mode 100755 datasources/mac/kubernetes/digitalocean/deployevents/installer/installer.bash create mode 100755 datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/functions.bash create mode 100644 datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/mac/kubernetes/eks/deployevents/installer/functions.bash create mode 100755 datasources/mac/kubernetes/eks/deployevents/installer/installer.bash create mode 100755 datasources/mac/kubernetes/eks/deployevents/prerequisites/functions.bash create mode 100644 datasources/mac/kubernetes/eks/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/mac/kubernetes/eks/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/mac/kubernetes/eks/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/mac/kubernetes/gke/deployevents/installer/functions.bash create mode 100755 datasources/mac/kubernetes/gke/deployevents/installer/installer.bash create mode 100755 datasources/mac/kubernetes/gke/deployevents/prerequisites/functions.bash create mode 100644 datasources/mac/kubernetes/gke/deployevents/prerequisites/prerequisites.bash create mode 100755 datasources/mac/kubernetes/gke/deployevents/telemetry/logs/functions.bash create mode 100755 datasources/mac/kubernetes/gke/deployevents/telemetry/logs/logs.bash create mode 100755 datasources/windows/kubernetes/aks/deployevents/installer/functions.ps1 create mode 100755 datasources/windows/kubernetes/aks/deployevents/installer/installer.ps1 create mode 100755 datasources/windows/kubernetes/aks/deployevents/prerequisites/functions.ps1 create mode 100644 datasources/windows/kubernetes/aks/deployevents/prerequisites/prerequisites.ps1 create mode 100755 datasources/windows/kubernetes/aks/deployevents/telemetry/logs/functions.ps1 create mode 100755 datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 create mode 100755 datasources/windows/kubernetes/digitalocean/deployevents/installer/functions.ps1 create mode 100755 datasources/windows/kubernetes/digitalocean/deployevents/installer/installer.ps1 create mode 100755 datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/functions.ps1 create mode 100644 datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.ps1 create mode 100755 datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/functions.ps1 create mode 100755 datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 create mode 100755 datasources/windows/kubernetes/eks/deployevents/installer/functions.ps1 create mode 100755 datasources/windows/kubernetes/eks/deployevents/installer/installer.ps1 create mode 100755 datasources/windows/kubernetes/eks/deployevents/prerequisites/functions.ps1 create mode 100644 datasources/windows/kubernetes/eks/deployevents/prerequisites/prerequisites.ps1 create mode 100755 datasources/windows/kubernetes/eks/deployevents/telemetry/logs/functions.ps1 create mode 100755 datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 create mode 100755 datasources/windows/kubernetes/gke/deployevents/installer/functions.ps1 create mode 100755 datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 create mode 100755 datasources/windows/kubernetes/gke/deployevents/prerequisites/functions.ps1 create mode 100644 datasources/windows/kubernetes/gke/deployevents/prerequisites/prerequisites.ps1 create mode 100755 datasources/windows/kubernetes/gke/deployevents/telemetry/logs/functions.ps1 create mode 100755 datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 diff --git a/datasources/linux/kubernetes/aks/deployevents/installer/functions.bash b/datasources/linux/kubernetes/aks/deployevents/installer/functions.bash new file mode 100755 index 000000000..dde70ce21 --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/installer/functions.bash @@ -0,0 +1,83 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Installer Functions ############################################### +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + env_id=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/linux/kubernetes/aks/deployevents/installer/installer.bash b/datasources/linux/kubernetes/aks/deployevents/installer/installer.bash new file mode 100755 index 000000000..3e6e16145 --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Installer Script ################################################ +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Security Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/linux/kubernetes/aks/deployevents/prerequisites/functions.bash b/datasources/linux/kubernetes/aks/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..7229d31f7 --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################## LINUX Datasource Prerequisites Functions ############################################# +################################################################################################################################# diff --git a/datasources/linux/kubernetes/aks/deployevents/prerequisites/prerequisites.bash b/datasources/linux/kubernetes/aks/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..4269857ef --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Prerequisites Script ############################################## +################################################################################################################################# diff --git a/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/functions.bash b/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..9cc5b4176 --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Logs Functions ################################################## +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/logs.bash b/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..983d6318f --- /dev/null +++ b/datasources/linux/kubernetes/aks/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ LINUX Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/installer/functions.bash b/datasources/linux/kubernetes/digitalocean/deployevents/installer/functions.bash new file mode 100755 index 000000000..dde70ce21 --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/installer/functions.bash @@ -0,0 +1,83 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Installer Functions ############################################### +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + env_id=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/installer/installer.bash b/datasources/linux/kubernetes/digitalocean/deployevents/installer/installer.bash new file mode 100755 index 000000000..3e6e16145 --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Installer Script ################################################ +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Security Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/functions.bash b/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..7229d31f7 --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################## LINUX Datasource Prerequisites Functions ############################################# +################################################################################################################################# diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash b/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..4269857ef --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Prerequisites Script ############################################## +################################################################################################################################# diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash b/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..9cc5b4176 --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Logs Functions ################################################## +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash b/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..983d6318f --- /dev/null +++ b/datasources/linux/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ LINUX Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/linux/kubernetes/eks/deployevents/installer/functions.bash b/datasources/linux/kubernetes/eks/deployevents/installer/functions.bash new file mode 100755 index 000000000..8208afe4a --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/installer/functions.bash @@ -0,0 +1,86 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Installer Functions ############################################### +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + local cluster_name + cluster_name=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + else + env_id=$(echo "$cluster_name" | cut -d'/' -f2) + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/linux/kubernetes/eks/deployevents/installer/installer.bash b/datasources/linux/kubernetes/eks/deployevents/installer/installer.bash new file mode 100755 index 000000000..8999e1b65 --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Installer Script ################################################ +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Deploy Events Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/linux/kubernetes/eks/deployevents/prerequisites/functions.bash b/datasources/linux/kubernetes/eks/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..7229d31f7 --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################## LINUX Datasource Prerequisites Functions ############################################# +################################################################################################################################# diff --git a/datasources/linux/kubernetes/eks/deployevents/prerequisites/prerequisites.bash b/datasources/linux/kubernetes/eks/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..4269857ef --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Prerequisites Script ############################################## +################################################################################################################################# diff --git a/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/functions.bash b/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..9cc5b4176 --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Logs Functions ################################################## +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/logs.bash b/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..983d6318f --- /dev/null +++ b/datasources/linux/kubernetes/eks/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ LINUX Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/linux/kubernetes/gke/deployevents/installer/functions.bash b/datasources/linux/kubernetes/gke/deployevents/installer/functions.bash new file mode 100755 index 000000000..6e580a30e --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/installer/functions.bash @@ -0,0 +1,86 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Installer Functions ############################################### +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + local cluster_name + cluster_name=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + else + env_id=$(echo "$cluster_name" | cut -d'_' -f2) + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/linux/kubernetes/gke/deployevents/installer/installer.bash b/datasources/linux/kubernetes/gke/deployevents/installer/installer.bash new file mode 100755 index 000000000..8999e1b65 --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Installer Script ################################################ +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Deploy Events Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/linux/kubernetes/gke/deployevents/prerequisites/functions.bash b/datasources/linux/kubernetes/gke/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..7229d31f7 --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################## LINUX Datasource Prerequisites Functions ############################################# +################################################################################################################################# diff --git a/datasources/linux/kubernetes/gke/deployevents/prerequisites/prerequisites.bash b/datasources/linux/kubernetes/gke/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..4269857ef --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################ LINUX Datasource Prerequisites Script ############################################## +################################################################################################################################# diff --git a/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/functions.bash b/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..9cc5b4176 --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################## LINUX Datasource Logs Functions ################################################## +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_LINUX_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/logs.bash b/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..983d6318f --- /dev/null +++ b/datasources/linux/kubernetes/gke/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ LINUX Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/mac/kubernetes/aks/deployevents/installer/functions.bash b/datasources/mac/kubernetes/aks/deployevents/installer/functions.bash new file mode 100755 index 000000000..5903bf8f7 --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/installer/functions.bash @@ -0,0 +1,83 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Installer Functions ################################################ +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + env_id=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/mac/kubernetes/aks/deployevents/installer/installer.bash b/datasources/mac/kubernetes/aks/deployevents/installer/installer.bash new file mode 100755 index 000000000..b4d7f28ff --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Installer Script ################################################# +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Security Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/mac/kubernetes/aks/deployevents/prerequisites/functions.bash b/datasources/mac/kubernetes/aks/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..ef1d48bd8 --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################### MAC Datasource Prerequisites Functions ############################################## +################################################################################################################################# diff --git a/datasources/mac/kubernetes/aks/deployevents/prerequisites/prerequisites.bash b/datasources/mac/kubernetes/aks/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..5ee978f21 --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Prerequisites Script ############################################### +################################################################################################################################# diff --git a/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/functions.bash b/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..3a7e56b02 --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Logs Functions ################################################### +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/logs.bash b/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..983d6318f --- /dev/null +++ b/datasources/mac/kubernetes/aks/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ LINUX Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/installer/functions.bash b/datasources/mac/kubernetes/digitalocean/deployevents/installer/functions.bash new file mode 100755 index 000000000..5903bf8f7 --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/installer/functions.bash @@ -0,0 +1,83 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Installer Functions ################################################ +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + env_id=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/installer/installer.bash b/datasources/mac/kubernetes/digitalocean/deployevents/installer/installer.bash new file mode 100755 index 000000000..6c4bd1273 --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Installer Script ################################################# +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Deploy Events Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/functions.bash b/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..ef1d48bd8 --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################### MAC Datasource Prerequisites Functions ############################################## +################################################################################################################################# diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash b/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..5ee978f21 --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Prerequisites Script ############################################### +################################################################################################################################# diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash b/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..3a7e56b02 --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Logs Functions ################################################### +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash b/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..01ace77ff --- /dev/null +++ b/datasources/mac/kubernetes/digitalocean/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ MAC Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/mac/kubernetes/eks/deployevents/installer/functions.bash b/datasources/mac/kubernetes/eks/deployevents/installer/functions.bash new file mode 100755 index 000000000..748c8e6a3 --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/installer/functions.bash @@ -0,0 +1,86 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Installer Functions ################################################ +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + local cluster_name + cluster_name=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + else + env_id=$(echo "$cluster_name" | cut -d'/' -f2) + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/mac/kubernetes/eks/deployevents/installer/installer.bash b/datasources/mac/kubernetes/eks/deployevents/installer/installer.bash new file mode 100755 index 000000000..6c4bd1273 --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Installer Script ################################################# +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Deploy Events Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/mac/kubernetes/eks/deployevents/prerequisites/functions.bash b/datasources/mac/kubernetes/eks/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..ef1d48bd8 --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################### MAC Datasource Prerequisites Functions ############################################## +################################################################################################################################# diff --git a/datasources/mac/kubernetes/eks/deployevents/prerequisites/prerequisites.bash b/datasources/mac/kubernetes/eks/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..5ee978f21 --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Prerequisites Script ############################################### +################################################################################################################################# diff --git a/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/functions.bash b/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..3a7e56b02 --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Logs Functions ################################################### +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/logs.bash b/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..01ace77ff --- /dev/null +++ b/datasources/mac/kubernetes/eks/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ MAC Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/mac/kubernetes/gke/deployevents/installer/functions.bash b/datasources/mac/kubernetes/gke/deployevents/installer/functions.bash new file mode 100755 index 000000000..fb165c554 --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/installer/functions.bash @@ -0,0 +1,86 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Installer Functions ################################################ +################################################################################################################################# + +# Loads datasource installer utils functions +# Input: +# --- +# Output: +# --- +function load_installer_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading installer utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_installer_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): error loading installer utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} + +# Gets environment id +# Input: +# --- +# Output: +# ENV_ID - The environment id +function get_environment_id { + local func_name="${FUNCNAME[0]}" + + local message='Getting environment id ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + PARAMS=("${GENERAL_PARAMS[@]}") + get_param_value 'envID' + if [[ $? -ne 0 ]]; then + message="installer.bash ($EXIT_CODE): $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_task_post_run "write_error \"$message\"" + + return $EXIT_CODE + fi + + local env_id="$PARAM_VALUE" + + if [[ "$env_id" == '' ]]; then + local cluster_name + cluster_name=$(kubectl config current-context 2>"$TASK_ERROR_FILE") + if [[ $? -ne 0 ]]; then + local err=$(get_task_error_message) + if [[ "$err" == *"ERROR"* ]]; then + env_id=$(echo "$RANDOM" | md5sum | cut -c 1-32) + fi + else + env_id=$(echo "$cluster_name" | cut -d'_' -f2) + fi + fi + + message="Environment id is '$env_id'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_INSTALLATION" "$LOG_SCRIPT_INSTALLER" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "ENV_ID='$env_id'" +} diff --git a/datasources/mac/kubernetes/gke/deployevents/installer/installer.bash b/datasources/mac/kubernetes/gke/deployevents/installer/installer.bash new file mode 100755 index 000000000..6c4bd1273 --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/installer/installer.bash @@ -0,0 +1,30 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Installer Script ################################################# +################################################################################################################################# + +# Print title +echo +echo -e '########################################' +echo -e "###$PURPLE_COLOR Deploy Events Datasource Installation $WHITE_COLOR###" +echo -e '########################################' + +EXIT_CODE=1 + +# Load datasource installer utils functions +load_installer_utils + +# Get the selected products +execute_task 'get_selected_products' 'Getting selected products' +# Get general params +execute_task 'get_general_params' 'Getting general params' +# Get environment id +execute_task 'get_environment_id' 'Getting environment id' + +DATA_SOURCE_INSTALLER_EXIT_CODE=$EXIT_CODE + +if $IS_LOGS_OPTION_WAS_SELECTED; then + # Run logs script + run_logs +fi diff --git a/datasources/mac/kubernetes/gke/deployevents/prerequisites/functions.bash b/datasources/mac/kubernetes/gke/deployevents/prerequisites/functions.bash new file mode 100755 index 000000000..ef1d48bd8 --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/prerequisites/functions.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +########################################### MAC Datasource Prerequisites Functions ############################################## +################################################################################################################################# diff --git a/datasources/mac/kubernetes/gke/deployevents/prerequisites/prerequisites.bash b/datasources/mac/kubernetes/gke/deployevents/prerequisites/prerequisites.bash new file mode 100644 index 000000000..5ee978f21 --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/prerequisites/prerequisites.bash @@ -0,0 +1,5 @@ +#!/bin/bash + +################################################################################################################################# +############################################# MAC Datasource Prerequisites Script ############################################### +################################################################################################################################# diff --git a/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/functions.bash b/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/functions.bash new file mode 100755 index 000000000..3a7e56b02 --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/functions.bash @@ -0,0 +1,42 @@ +#!/bin/bash + +################################################################################################################################# +############################################### MAC Datasource Logs Functions ################################################### +################################################################################################################################# + +# Loads datasource logs utils functions +# Input: +# --- +# Output: +# --- +function load_logs_utils { + local func_name="${FUNCNAME[0]}" + + local message='Loading logs utils functions ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + source "$ALL_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + source "$KUBERNETES_RESOURCES_MAC_DIR/datasource_logs_utils.bash" 2>"$TASK_ERROR_FILE" + if [[ $? -ne 0 ]]; then + message="logs.bash ($EXIT_CODE): error loading logs utils functions: $(get_task_error_message)" + send_log_to_logzio "$LOG_LEVEL_ERROR" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_error "$message" + + IS_AGENT_FAILED=true + run_final + exit $EXIT_CODE + fi + + ((EXIT_CODE++)) +} diff --git a/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/logs.bash b/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/logs.bash new file mode 100755 index 000000000..01ace77ff --- /dev/null +++ b/datasources/mac/kubernetes/gke/deployevents/telemetry/logs/logs.bash @@ -0,0 +1,27 @@ +#!/bin/bash + +################################################################################################################################# +################################################ MAC Datasource Logs Script ################################################### +################################################################################################################################# + +# Print title +echo +echo -e '############' +echo -e "###$PURPLE_COLOR Logs $WHITE_COLOR###" +echo -e '############' + +EXIT_CODE=1 + +# Load datasource logs utils functions +load_logs_utils + +# Get Logz.io logs token +execute_task 'get_logzio_logs_token' 'Getting Logz.io logs token' +# Build enable deploy events Helm set +execute_task "build_enable_deploy_events_helm_set" "Building enable deploy events Helm set" +# Build Logz.io deploy events logs listener URL Helm set +execute_task "build_logzio_deploy_events_logs_listener_url_helm_set" "Building Logz.io deploy events logs listener URL Helm set" +# Build Logz.io deploy events logs token Helm set +execute_task "build_logzio_deploy_events_logs_token_helm_set" "Building Logz.io deploy events logs token Helm set" +# Build Deploy events environment id Helm set +execute_task "build_deploy_events_environment_id_helm_set" "Building deploy events environment id Helm set" diff --git a/datasources/windows/kubernetes/aks/deployevents/installer/functions.ps1 b/datasources/windows/kubernetes/aks/deployevents/installer/functions.ps1 new file mode 100755 index 000000000..b52a03570 --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/installer/functions.ps1 @@ -0,0 +1,229 @@ +################################################################################################################################# +################################################# WINDOWS Installer Functions ################################################### +################################################################################################################################# + +# Gets the selected products (logs/metrics/traces) +# Input: +# --- +# Output: +# IsLogsOptionSelected - Tells if logs option was selected (true/false) +# LogsTelemetry - The logs telemetry if logs option was selected +# LogsParams - The logs params if logs option was selected +# IsMetricsOptionSelected - Tells if metrics option was selected (true/false) +# MetricsTelemetry - The metrics telemetry if metrics option was selected +# MetricsParams - The metrics params if metrics option was selected +# IsTracesOptionSelected - Tells if traces option was selected (true/false) +# TracesTelemetry - The traces telemetry if traces option was selected +# TracesParams - The traces params if traces option was selected +function Get-SelectedProducts { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting the selected products ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].telemetries[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Telemetries = $script:JsonValue + + $local:IsLogsOptionSelected = $false + $local:IsMetricsOptionSelected = $false + $local:IsTracesOptionSelected = $false + + $local:TelemetryIndex = 0 + foreach ($Telemetry in $Telemetries) { + $Err = Get-JsonStrFieldValue $Telemetry '.type' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Type = $script:JsonValue + $local:Params = $null + + $Err = Get-JsonStrFieldValueList $Telemetry '.params[]' + if ($Err.Count -ne 0 -and $Err[1] -ne 2) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + if ($Err.Count -ne 0) { + $Params = '' + } + else { + $Params = $script:JsonValue + } + + $local:ParamsStr = Convert-ListToStr $Params + + if ($Type.Equals('LOG_ANALYTICS')) { + $Message = 'Logs option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsLogsOptionSelected = $true + Write-TaskPostRun "`$script:LogsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:LogsParams = $ParamsStr" + } + elseif ($Type.Equals('METRICS')) { + $Message = 'Metrics option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsMetricsOptionSelected = $true + Write-TaskPostRun "`$script:MetricsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:MetricsParams = $ParamsStr" + } + elseif ($Type.Equals('TRACING')) { + $Message = 'Traces option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsTracesOptionSelected = $true + Write-TaskPostRun "`$script:TracesTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:TracesParams = $ParamsStr" + } + + $TelemetryIndex++ + } + + Write-TaskPostRun "`$script:IsLogsOptionSelected = `$$IsLogsOptionSelected" + Write-TaskPostRun "`$script:IsMetricsOptionSelected = `$$IsMetricsOptionSelected" + Write-TaskPostRun "`$script:IsTracesOptionSelected = `$$IsTracesOptionSelected" +} + +# Gets general params (params under datasource) +# Input: +# --- +# Output: +# GeneralParams - The params under datasource +function Get-GeneralParams { + $local:ExitCode = 2 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting general params ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].params[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Params = $script:JsonValue + + $Message = "General params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:ParamsStr = Convert-ListToStr $Params + + Write-TaskPostRun "`$script:GeneralParams = $ParamsStr" +} + +# Gets environment id +# Input: +# FuncArgs - Hashtable {GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} +# Output: +# EnvId - The environment id +function Get-EnvironmentID { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting environment id ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('GeneralParams', 'DefaultEnvId') + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:GeneralParams = $FuncArgs.GeneralParams + $local:DefaultEnvId = $FuncArgs.DefaultEnvId + + $Err = Get-ParamValue $GeneralParams 'envID' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $script:ParamValue + + if ([string]::IsNullOrEmpty($EnvId)) { + $EnvId = kubectl config current-context 2>$Null + if ($LASTEXITCODE -ne 0) { + $EnvId = $DefaultEnvId + } + } + + $Message = "Environment id is '$EnvId'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:EnvId = '$EnvId'" +} diff --git a/datasources/windows/kubernetes/aks/deployevents/installer/installer.ps1 b/datasources/windows/kubernetes/aks/deployevents/installer/installer.ps1 new file mode 100755 index 000000000..c69b0ca19 --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/installer/installer.ps1 @@ -0,0 +1,55 @@ +################################################################################################################################# +################################################### WINDOWS Installer Script #################################################### +################################################################################################################################# + +# Runs logs script +# Input: +# --- +# Output: +# --- +function Invoke-Logs { + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = "Running $CurrentDataSource datasource logs script ..." + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + try { + . "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFile" -ErrorAction Stop + if ($LASTEXITCODE -ne 0) { + Exit $LASTEXITCODE + } + } + catch { + $local:Message = "installer.ps1 ($ExitCode): error running $CurrentDataSource datasource logs script: $_" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Error $Message + + $script:IsAgentFailed = $true + Exit $ExitCode + } +} + + +$local:InstallerFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:InstallerFunctionsFile" + +# Print title +Write-Host +Write-Host '##########################################' +Write-Host '### ' -NoNewline +Write-Host 'Security Datasource Installation' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '##########################################' + +# Get the selected products +Invoke-Task 'Get-SelectedProducts' @{} 'Getting the selected products' @($InstallerFunctionsScript) +# Get general params +Invoke-Task 'Get-GeneralParams' @{} 'Getting general params' @($InstallerFunctionsScript) +# Get environment id +Invoke-Task 'Get-EnvironmentID' @{GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} 'Getting environment id' @($InstallerFunctionsScript) +# Run logs script +Invoke-Logs + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/aks/deployevents/prerequisites/functions.ps1 b/datasources/windows/kubernetes/aks/deployevents/prerequisites/functions.ps1 new file mode 100755 index 000000000..95845e48b --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/prerequisites/functions.ps1 @@ -0,0 +1,3 @@ +################################################################################################################################# +############################################### WINDOWS Prerequisites Functions ################################################# +################################################################################################################################# diff --git a/datasources/windows/kubernetes/aks/deployevents/prerequisites/prerequisites.ps1 b/datasources/windows/kubernetes/aks/deployevents/prerequisites/prerequisites.ps1 new file mode 100644 index 000000000..a532fb1a5 --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/prerequisites/prerequisites.ps1 @@ -0,0 +1,6 @@ +################################################################################################################################# +################################################# WINDOWS Prerequisites Script ################################################## +################################################################################################################################# + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/functions.ps1 b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/functions.ps1 new file mode 100755 index 000000000..257cff67a --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/functions.ps1 @@ -0,0 +1,182 @@ +################################################################################################################################# +################################################### WINDOWS Logs Functions ###################################################### +################################################################################################################################# + +# Gets Logz.io logs token +# Input: +# --- +# Output: +# LogsToken - Logz.io logs token +function Get-LogzioLogsToken { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting Logz.io logs token ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Get-JsonFileFieldValue $script:AgentJson '.shippingTokens.LOG_ANALYTICS' + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ShippingToken = $script:JsonValue + + $Message = "Logz.io logs token is '$ShippingToken'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogsToken = '$ShippingToken'" +} + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-EnableDeployEventsHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building enable deploy events Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set deployEvents.enabled=true" + + $Message = "Enable deploy events Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs listener url Helm set +# Input: +# FuncArgs - Hashtable {ListenerUrl = $script:ListenerUrl} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsListenerUrlHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 6 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs listener URL Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('ListenerUrl') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ListenerUrl = $FuncArgs.ListenerUrl + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioListener=$ListenerUrl" + + $Message = "Logz.io deploy events logs listener url Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# FuncArgs - Hashtable {LogsToken = $script:LogsToken} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsTokenHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 7 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs token Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('LogsToken') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:LogsToken = $FuncArgs.LogsToken + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioShippingToken=$LogsToken" + + $Message = "Logz.io deploy events logs token Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Deploy events environment id Helm set +# Input: +# FuncArgs - Hashtable {EnvId = $script:EnvId} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-DeployEventsEnvironmentIdHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building deploy events environment id Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('EnvId') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $FuncArgs.EnvId + + if ([string]::IsNullOrEmpty($EnvId)) { + $Message = 'Environment id is empty. Default value will be used' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + return + } + + $local:HelmSet = " --set logzio-k8s-events.secrets.env_id=$EnvId" + + $Message = "Deploy events Environment id Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 new file mode 100755 index 000000000..b212d5482 --- /dev/null +++ b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 @@ -0,0 +1,27 @@ +################################################################################################################################# +##################################################### WINDOWS Logs Script ####################################################### +################################################################################################################################# + +$local:LogsFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFunctionsFile" + +# Print headline +Write-Host +Write-Host '############' +Write-Host '### ' -NoNewline +Write-Host 'Logs' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '############' + +# Get Logz.io logs token +Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) +# Build enable security report Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs listener url Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs token Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsTokenHelmSet' @{LogsToken = $script:LogsToken} 'Building Logz.io deploy events logs token Helm set' @($LogsFunctionsScript) +# Build Deploy events environment id Helm set +Invoke-Task 'Build-DeployEventsEnvironmentIdHelmSet' @{EnvId = $script:EnvId} 'Building Deploy events environment id Helm set' @($LogsFunctionsScript) + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/installer/functions.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/installer/functions.ps1 new file mode 100755 index 000000000..b52a03570 --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/installer/functions.ps1 @@ -0,0 +1,229 @@ +################################################################################################################################# +################################################# WINDOWS Installer Functions ################################################### +################################################################################################################################# + +# Gets the selected products (logs/metrics/traces) +# Input: +# --- +# Output: +# IsLogsOptionSelected - Tells if logs option was selected (true/false) +# LogsTelemetry - The logs telemetry if logs option was selected +# LogsParams - The logs params if logs option was selected +# IsMetricsOptionSelected - Tells if metrics option was selected (true/false) +# MetricsTelemetry - The metrics telemetry if metrics option was selected +# MetricsParams - The metrics params if metrics option was selected +# IsTracesOptionSelected - Tells if traces option was selected (true/false) +# TracesTelemetry - The traces telemetry if traces option was selected +# TracesParams - The traces params if traces option was selected +function Get-SelectedProducts { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting the selected products ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].telemetries[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Telemetries = $script:JsonValue + + $local:IsLogsOptionSelected = $false + $local:IsMetricsOptionSelected = $false + $local:IsTracesOptionSelected = $false + + $local:TelemetryIndex = 0 + foreach ($Telemetry in $Telemetries) { + $Err = Get-JsonStrFieldValue $Telemetry '.type' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Type = $script:JsonValue + $local:Params = $null + + $Err = Get-JsonStrFieldValueList $Telemetry '.params[]' + if ($Err.Count -ne 0 -and $Err[1] -ne 2) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + if ($Err.Count -ne 0) { + $Params = '' + } + else { + $Params = $script:JsonValue + } + + $local:ParamsStr = Convert-ListToStr $Params + + if ($Type.Equals('LOG_ANALYTICS')) { + $Message = 'Logs option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsLogsOptionSelected = $true + Write-TaskPostRun "`$script:LogsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:LogsParams = $ParamsStr" + } + elseif ($Type.Equals('METRICS')) { + $Message = 'Metrics option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsMetricsOptionSelected = $true + Write-TaskPostRun "`$script:MetricsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:MetricsParams = $ParamsStr" + } + elseif ($Type.Equals('TRACING')) { + $Message = 'Traces option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsTracesOptionSelected = $true + Write-TaskPostRun "`$script:TracesTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:TracesParams = $ParamsStr" + } + + $TelemetryIndex++ + } + + Write-TaskPostRun "`$script:IsLogsOptionSelected = `$$IsLogsOptionSelected" + Write-TaskPostRun "`$script:IsMetricsOptionSelected = `$$IsMetricsOptionSelected" + Write-TaskPostRun "`$script:IsTracesOptionSelected = `$$IsTracesOptionSelected" +} + +# Gets general params (params under datasource) +# Input: +# --- +# Output: +# GeneralParams - The params under datasource +function Get-GeneralParams { + $local:ExitCode = 2 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting general params ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].params[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Params = $script:JsonValue + + $Message = "General params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:ParamsStr = Convert-ListToStr $Params + + Write-TaskPostRun "`$script:GeneralParams = $ParamsStr" +} + +# Gets environment id +# Input: +# FuncArgs - Hashtable {GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} +# Output: +# EnvId - The environment id +function Get-EnvironmentID { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting environment id ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('GeneralParams', 'DefaultEnvId') + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:GeneralParams = $FuncArgs.GeneralParams + $local:DefaultEnvId = $FuncArgs.DefaultEnvId + + $Err = Get-ParamValue $GeneralParams 'envID' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $script:ParamValue + + if ([string]::IsNullOrEmpty($EnvId)) { + $EnvId = kubectl config current-context 2>$Null + if ($LASTEXITCODE -ne 0) { + $EnvId = $DefaultEnvId + } + } + + $Message = "Environment id is '$EnvId'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:EnvId = '$EnvId'" +} diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/installer/installer.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/installer/installer.ps1 new file mode 100755 index 000000000..c69b0ca19 --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/installer/installer.ps1 @@ -0,0 +1,55 @@ +################################################################################################################################# +################################################### WINDOWS Installer Script #################################################### +################################################################################################################################# + +# Runs logs script +# Input: +# --- +# Output: +# --- +function Invoke-Logs { + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = "Running $CurrentDataSource datasource logs script ..." + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + try { + . "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFile" -ErrorAction Stop + if ($LASTEXITCODE -ne 0) { + Exit $LASTEXITCODE + } + } + catch { + $local:Message = "installer.ps1 ($ExitCode): error running $CurrentDataSource datasource logs script: $_" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Error $Message + + $script:IsAgentFailed = $true + Exit $ExitCode + } +} + + +$local:InstallerFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:InstallerFunctionsFile" + +# Print title +Write-Host +Write-Host '##########################################' +Write-Host '### ' -NoNewline +Write-Host 'Security Datasource Installation' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '##########################################' + +# Get the selected products +Invoke-Task 'Get-SelectedProducts' @{} 'Getting the selected products' @($InstallerFunctionsScript) +# Get general params +Invoke-Task 'Get-GeneralParams' @{} 'Getting general params' @($InstallerFunctionsScript) +# Get environment id +Invoke-Task 'Get-EnvironmentID' @{GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} 'Getting environment id' @($InstallerFunctionsScript) +# Run logs script +Invoke-Logs + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/functions.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/functions.ps1 new file mode 100755 index 000000000..95845e48b --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/functions.ps1 @@ -0,0 +1,3 @@ +################################################################################################################################# +############################################### WINDOWS Prerequisites Functions ################################################# +################################################################################################################################# diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.ps1 new file mode 100644 index 000000000..a532fb1a5 --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/prerequisites/prerequisites.ps1 @@ -0,0 +1,6 @@ +################################################################################################################################# +################################################# WINDOWS Prerequisites Script ################################################## +################################################################################################################################# + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/functions.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/functions.ps1 new file mode 100755 index 000000000..257cff67a --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/functions.ps1 @@ -0,0 +1,182 @@ +################################################################################################################################# +################################################### WINDOWS Logs Functions ###################################################### +################################################################################################################################# + +# Gets Logz.io logs token +# Input: +# --- +# Output: +# LogsToken - Logz.io logs token +function Get-LogzioLogsToken { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting Logz.io logs token ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Get-JsonFileFieldValue $script:AgentJson '.shippingTokens.LOG_ANALYTICS' + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ShippingToken = $script:JsonValue + + $Message = "Logz.io logs token is '$ShippingToken'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogsToken = '$ShippingToken'" +} + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-EnableDeployEventsHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building enable deploy events Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set deployEvents.enabled=true" + + $Message = "Enable deploy events Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs listener url Helm set +# Input: +# FuncArgs - Hashtable {ListenerUrl = $script:ListenerUrl} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsListenerUrlHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 6 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs listener URL Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('ListenerUrl') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ListenerUrl = $FuncArgs.ListenerUrl + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioListener=$ListenerUrl" + + $Message = "Logz.io deploy events logs listener url Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# FuncArgs - Hashtable {LogsToken = $script:LogsToken} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsTokenHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 7 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs token Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('LogsToken') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:LogsToken = $FuncArgs.LogsToken + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioShippingToken=$LogsToken" + + $Message = "Logz.io deploy events logs token Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Deploy events environment id Helm set +# Input: +# FuncArgs - Hashtable {EnvId = $script:EnvId} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-DeployEventsEnvironmentIdHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building deploy events environment id Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('EnvId') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $FuncArgs.EnvId + + if ([string]::IsNullOrEmpty($EnvId)) { + $Message = 'Environment id is empty. Default value will be used' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + return + } + + $local:HelmSet = " --set logzio-k8s-events.secrets.env_id=$EnvId" + + $Message = "Deploy events Environment id Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 new file mode 100755 index 000000000..b212d5482 --- /dev/null +++ b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 @@ -0,0 +1,27 @@ +################################################################################################################################# +##################################################### WINDOWS Logs Script ####################################################### +################################################################################################################################# + +$local:LogsFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFunctionsFile" + +# Print headline +Write-Host +Write-Host '############' +Write-Host '### ' -NoNewline +Write-Host 'Logs' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '############' + +# Get Logz.io logs token +Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) +# Build enable security report Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs listener url Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs token Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsTokenHelmSet' @{LogsToken = $script:LogsToken} 'Building Logz.io deploy events logs token Helm set' @($LogsFunctionsScript) +# Build Deploy events environment id Helm set +Invoke-Task 'Build-DeployEventsEnvironmentIdHelmSet' @{EnvId = $script:EnvId} 'Building Deploy events environment id Helm set' @($LogsFunctionsScript) + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/eks/deployevents/installer/functions.ps1 b/datasources/windows/kubernetes/eks/deployevents/installer/functions.ps1 new file mode 100755 index 000000000..147aa3713 --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/installer/functions.ps1 @@ -0,0 +1,231 @@ +################################################################################################################################# +################################################# WINDOWS Installer Functions ################################################### +################################################################################################################################# + +# Gets the selected products (logs/metrics/traces) +# Input: +# --- +# Output: +# IsLogsOptionSelected - Tells if logs option was selected (true/false) +# LogsTelemetry - The logs telemetry if logs option was selected +# LogsParams - The logs params if logs option was selected +# IsMetricsOptionSelected - Tells if metrics option was selected (true/false) +# MetricsTelemetry - The metrics telemetry if metrics option was selected +# MetricsParams - The metrics params if metrics option was selected +# IsTracesOptionSelected - Tells if traces option was selected (true/false) +# TracesTelemetry - The traces telemetry if traces option was selected +# TracesParams - The traces params if traces option was selected +function Get-SelectedProducts { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting the selected products ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].telemetries[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Telemetries = $script:JsonValue + + $local:IsLogsOptionSelected = $false + $local:IsMetricsOptionSelected = $false + $local:IsTracesOptionSelected = $false + + $local:TelemetryIndex = 0 + foreach ($Telemetry in $Telemetries) { + $Err = Get-JsonStrFieldValue $Telemetry '.type' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Type = $script:JsonValue + $local:Params = $null + + $Err = Get-JsonStrFieldValueList $Telemetry '.params[]' + if ($Err.Count -ne 0 -and $Err[1] -ne 2) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + if ($Err.Count -ne 0) { + $Params = '' + } + else { + $Params = $script:JsonValue + } + + $local:ParamsStr = Convert-ListToStr $Params + + if ($Type.Equals('LOG_ANALYTICS')) { + $Message = 'Logs option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsLogsOptionSelected = $true + Write-TaskPostRun "`$script:LogsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:LogsParams = $ParamsStr" + } + elseif ($Type.Equals('METRICS')) { + $Message = 'Metrics option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsMetricsOptionSelected = $true + Write-TaskPostRun "`$script:MetricsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:MetricsParams = $ParamsStr" + } + elseif ($Type.Equals('TRACING')) { + $Message = 'Traces option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsTracesOptionSelected = $true + Write-TaskPostRun "`$script:TracesTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:TracesParams = $ParamsStr" + } + + $TelemetryIndex++ + } + + Write-TaskPostRun "`$script:IsLogsOptionSelected = `$$IsLogsOptionSelected" + Write-TaskPostRun "`$script:IsMetricsOptionSelected = `$$IsMetricsOptionSelected" + Write-TaskPostRun "`$script:IsTracesOptionSelected = `$$IsTracesOptionSelected" +} + +# Gets general params (params under datasource) +# Input: +# --- +# Output: +# GeneralParams - The params under datasource +function Get-GeneralParams { + $local:ExitCode = 2 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting general params ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].params[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Params = $script:JsonValue + + $Message = "General params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:ParamsStr = Convert-ListToStr $Params + + Write-TaskPostRun "`$script:GeneralParams = $ParamsStr" +} + +# Gets environment id +# Input: +# FuncArgs - Hashtable {GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} +# Output: +# EnvId - The environment id +function Get-EnvironmentID { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting environment id ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('GeneralParams', 'DefaultEnvId') + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:GeneralParams = $FuncArgs.GeneralParams + $local:DefaultEnvId = $FuncArgs.DefaultEnvId + + $Err = Get-ParamValue $GeneralParams 'envID' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $script:ParamValue + + if ([string]::IsNullOrEmpty($EnvId)) { + $local:ClusterName = kubectl config current-context 2>$Null + if ($LASTEXITCODE -ne 0) { + $EnvId = $DefaultEnvId + } else { + $EnvId = $ClusterName.Split('/')[1] + } + } + + $Message = "Environment id is '$EnvId'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:EnvId = '$EnvId'" +} diff --git a/datasources/windows/kubernetes/eks/deployevents/installer/installer.ps1 b/datasources/windows/kubernetes/eks/deployevents/installer/installer.ps1 new file mode 100755 index 000000000..4d2d33191 --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/installer/installer.ps1 @@ -0,0 +1,55 @@ +################################################################################################################################# +################################################### WINDOWS Installer Script #################################################### +################################################################################################################################# + +# Runs logs script +# Input: +# --- +# Output: +# --- +function Invoke-Logs { + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = "Running $CurrentDataSource datasource logs script ..." + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + try { + . "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFile" -ErrorAction Stop + if ($LASTEXITCODE -ne 0) { + Exit $LASTEXITCODE + } + } + catch { + $local:Message = "installer.ps1 ($ExitCode): error running $CurrentDataSource datasource logs script: $_" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Error $Message + + $script:IsAgentFailed = $true + Exit $ExitCode + } +} + + +$local:InstallerFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:InstallerFunctionsFile" + +# Print title +Write-Host +Write-Host '##########################################' +Write-Host '### ' -NoNewline +Write-Host 'Deploy Events Datasource Installation' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '##########################################' + +# Get the selected products +Invoke-Task 'Get-SelectedProducts' @{} 'Getting the selected products' @($InstallerFunctionsScript) +# Get general params +Invoke-Task 'Get-GeneralParams' @{} 'Getting general params' @($InstallerFunctionsScript) +# Get environment id +Invoke-Task 'Get-EnvironmentID' @{GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} 'Getting environment id' @($InstallerFunctionsScript) +# Run logs script +Invoke-Logs + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/eks/deployevents/prerequisites/functions.ps1 b/datasources/windows/kubernetes/eks/deployevents/prerequisites/functions.ps1 new file mode 100755 index 000000000..95845e48b --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/prerequisites/functions.ps1 @@ -0,0 +1,3 @@ +################################################################################################################################# +############################################### WINDOWS Prerequisites Functions ################################################# +################################################################################################################################# diff --git a/datasources/windows/kubernetes/eks/deployevents/prerequisites/prerequisites.ps1 b/datasources/windows/kubernetes/eks/deployevents/prerequisites/prerequisites.ps1 new file mode 100644 index 000000000..a532fb1a5 --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/prerequisites/prerequisites.ps1 @@ -0,0 +1,6 @@ +################################################################################################################################# +################################################# WINDOWS Prerequisites Script ################################################## +################################################################################################################################# + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/functions.ps1 b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/functions.ps1 new file mode 100755 index 000000000..257cff67a --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/functions.ps1 @@ -0,0 +1,182 @@ +################################################################################################################################# +################################################### WINDOWS Logs Functions ###################################################### +################################################################################################################################# + +# Gets Logz.io logs token +# Input: +# --- +# Output: +# LogsToken - Logz.io logs token +function Get-LogzioLogsToken { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting Logz.io logs token ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Get-JsonFileFieldValue $script:AgentJson '.shippingTokens.LOG_ANALYTICS' + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ShippingToken = $script:JsonValue + + $Message = "Logz.io logs token is '$ShippingToken'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogsToken = '$ShippingToken'" +} + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-EnableDeployEventsHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building enable deploy events Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set deployEvents.enabled=true" + + $Message = "Enable deploy events Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs listener url Helm set +# Input: +# FuncArgs - Hashtable {ListenerUrl = $script:ListenerUrl} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsListenerUrlHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 6 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs listener URL Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('ListenerUrl') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ListenerUrl = $FuncArgs.ListenerUrl + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioListener=$ListenerUrl" + + $Message = "Logz.io deploy events logs listener url Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# FuncArgs - Hashtable {LogsToken = $script:LogsToken} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsTokenHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 7 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs token Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('LogsToken') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:LogsToken = $FuncArgs.LogsToken + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioShippingToken=$LogsToken" + + $Message = "Logz.io deploy events logs token Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Deploy events environment id Helm set +# Input: +# FuncArgs - Hashtable {EnvId = $script:EnvId} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-DeployEventsEnvironmentIdHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building deploy events environment id Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('EnvId') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $FuncArgs.EnvId + + if ([string]::IsNullOrEmpty($EnvId)) { + $Message = 'Environment id is empty. Default value will be used' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + return + } + + $local:HelmSet = " --set logzio-k8s-events.secrets.env_id=$EnvId" + + $Message = "Deploy events Environment id Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 new file mode 100755 index 000000000..b212d5482 --- /dev/null +++ b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 @@ -0,0 +1,27 @@ +################################################################################################################################# +##################################################### WINDOWS Logs Script ####################################################### +################################################################################################################################# + +$local:LogsFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFunctionsFile" + +# Print headline +Write-Host +Write-Host '############' +Write-Host '### ' -NoNewline +Write-Host 'Logs' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '############' + +# Get Logz.io logs token +Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) +# Build enable security report Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs listener url Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs token Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsTokenHelmSet' @{LogsToken = $script:LogsToken} 'Building Logz.io deploy events logs token Helm set' @($LogsFunctionsScript) +# Build Deploy events environment id Helm set +Invoke-Task 'Build-DeployEventsEnvironmentIdHelmSet' @{EnvId = $script:EnvId} 'Building Deploy events environment id Helm set' @($LogsFunctionsScript) + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/gke/deployevents/installer/functions.ps1 b/datasources/windows/kubernetes/gke/deployevents/installer/functions.ps1 new file mode 100755 index 000000000..121c5e53e --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/installer/functions.ps1 @@ -0,0 +1,231 @@ +################################################################################################################################# +################################################# WINDOWS Installer Functions ################################################### +################################################################################################################################# + +# Gets the selected products (logs/metrics/traces) +# Input: +# --- +# Output: +# IsLogsOptionSelected - Tells if logs option was selected (true/false) +# LogsTelemetry - The logs telemetry if logs option was selected +# LogsParams - The logs params if logs option was selected +# IsMetricsOptionSelected - Tells if metrics option was selected (true/false) +# MetricsTelemetry - The metrics telemetry if metrics option was selected +# MetricsParams - The metrics params if metrics option was selected +# IsTracesOptionSelected - Tells if traces option was selected (true/false) +# TracesTelemetry - The traces telemetry if traces option was selected +# TracesParams - The traces params if traces option was selected +function Get-SelectedProducts { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting the selected products ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].telemetries[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Telemetries = $script:JsonValue + + $local:IsLogsOptionSelected = $false + $local:IsMetricsOptionSelected = $false + $local:IsTracesOptionSelected = $false + + $local:TelemetryIndex = 0 + foreach ($Telemetry in $Telemetries) { + $Err = Get-JsonStrFieldValue $Telemetry '.type' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Type = $script:JsonValue + $local:Params = $null + + $Err = Get-JsonStrFieldValueList $Telemetry '.params[]' + if ($Err.Count -ne 0 -and $Err[1] -ne 2) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + if ($Err.Count -ne 0) { + $Params = '' + } + else { + $Params = $script:JsonValue + } + + $local:ParamsStr = Convert-ListToStr $Params + + if ($Type.Equals('LOG_ANALYTICS')) { + $Message = 'Logs option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Logs params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsLogsOptionSelected = $true + Write-TaskPostRun "`$script:LogsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:LogsParams = $ParamsStr" + } + elseif ($Type.Equals('METRICS')) { + $Message = 'Metrics option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Metrics params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsMetricsOptionSelected = $true + Write-TaskPostRun "`$script:MetricsTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:MetricsParams = $ParamsStr" + } + elseif ($Type.Equals('TRACING')) { + $Message = 'Traces option was selected' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces telemetry is '$Telemetry'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + $Message = "Traces params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $IsTracesOptionSelected = $true + Write-TaskPostRun "`$script:TracesTelemetry = '$Telemetry'" + Write-TaskPostRun "`$script:TracesParams = $ParamsStr" + } + + $TelemetryIndex++ + } + + Write-TaskPostRun "`$script:IsLogsOptionSelected = `$$IsLogsOptionSelected" + Write-TaskPostRun "`$script:IsMetricsOptionSelected = `$$IsMetricsOptionSelected" + Write-TaskPostRun "`$script:IsTracesOptionSelected = `$$IsTracesOptionSelected" +} + +# Gets general params (params under datasource) +# Input: +# --- +# Output: +# GeneralParams - The params under datasource +function Get-GeneralParams { + $local:ExitCode = 2 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting general params ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:DataSourceIndex = 0 + foreach ($DataSource in $script:DataSources) { + if ($Datasource.Equals($script:CurrentDataSource)) { + break + } + + $DataSourceIndex++ + } + + $local:Err = Get-JsonFileFieldValueList $script:AgentJson ".configuration.subtypes[0].datasources[$DataSourceIndex].params[]" + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:Params = $script:JsonValue + + $Message = "General params are '$Params'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:ParamsStr = Convert-ListToStr $Params + + Write-TaskPostRun "`$script:GeneralParams = $ParamsStr" +} + +# Gets environment id +# Input: +# FuncArgs - Hashtable {GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} +# Output: +# EnvId - The environment id +function Get-EnvironmentID { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 4 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting environment id ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('GeneralParams', 'DefaultEnvId') + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:GeneralParams = $FuncArgs.GeneralParams + $local:DefaultEnvId = $FuncArgs.DefaultEnvId + + $Err = Get-ParamValue $GeneralParams 'envID' + if ($Err.Count -ne 0) { + $Message = "installer.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $script:ParamValue + + if ([string]::IsNullOrEmpty($EnvId)) { + $local:ClusterName = kubectl config current-context 2>$Null + if ($LASTEXITCODE -ne 0) { + $EnvId = $DefaultEnvId + } else { + $EnvId = $ClusterName.Split('_')[1] + } + } + + $Message = "Environment id is '$EnvId'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:EnvId = '$EnvId'" +} diff --git a/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 b/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 new file mode 100755 index 000000000..c69b0ca19 --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 @@ -0,0 +1,55 @@ +################################################################################################################################# +################################################### WINDOWS Installer Script #################################################### +################################################################################################################################# + +# Runs logs script +# Input: +# --- +# Output: +# --- +function Invoke-Logs { + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = "Running $CurrentDataSource datasource logs script ..." + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + try { + . "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFile" -ErrorAction Stop + if ($LASTEXITCODE -ne 0) { + Exit $LASTEXITCODE + } + } + catch { + $local:Message = "installer.ps1 ($ExitCode): error running $CurrentDataSource datasource logs script: $_" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepInstallation $script:LogScriptInstaller $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Error $Message + + $script:IsAgentFailed = $true + Exit $ExitCode + } +} + + +$local:InstallerFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:InstallerFunctionsFile" + +# Print title +Write-Host +Write-Host '##########################################' +Write-Host '### ' -NoNewline +Write-Host 'Security Datasource Installation' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '##########################################' + +# Get the selected products +Invoke-Task 'Get-SelectedProducts' @{} 'Getting the selected products' @($InstallerFunctionsScript) +# Get general params +Invoke-Task 'Get-GeneralParams' @{} 'Getting general params' @($InstallerFunctionsScript) +# Get environment id +Invoke-Task 'Get-EnvironmentID' @{GeneralParams = $script:GeneralParams; DefaultEnvId = $script:DefaultEnvId} 'Getting environment id' @($InstallerFunctionsScript) +# Run logs script +Invoke-Logs + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/gke/deployevents/prerequisites/functions.ps1 b/datasources/windows/kubernetes/gke/deployevents/prerequisites/functions.ps1 new file mode 100755 index 000000000..95845e48b --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/prerequisites/functions.ps1 @@ -0,0 +1,3 @@ +################################################################################################################################# +############################################### WINDOWS Prerequisites Functions ################################################# +################################################################################################################################# diff --git a/datasources/windows/kubernetes/gke/deployevents/prerequisites/prerequisites.ps1 b/datasources/windows/kubernetes/gke/deployevents/prerequisites/prerequisites.ps1 new file mode 100644 index 000000000..a532fb1a5 --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/prerequisites/prerequisites.ps1 @@ -0,0 +1,6 @@ +################################################################################################################################# +################################################# WINDOWS Prerequisites Script ################################################## +################################################################################################################################# + +# Finished successfully +Exit 0 diff --git a/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/functions.ps1 b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/functions.ps1 new file mode 100755 index 000000000..257cff67a --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/functions.ps1 @@ -0,0 +1,182 @@ +################################################################################################################################# +################################################### WINDOWS Logs Functions ###################################################### +################################################################################################################################# + +# Gets Logz.io logs token +# Input: +# --- +# Output: +# LogsToken - Logz.io logs token +function Get-LogzioLogsToken { + $local:ExitCode = 1 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Getting Logz.io logs token ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Get-JsonFileFieldValue $script:AgentJson '.shippingTokens.LOG_ANALYTICS' + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ShippingToken = $script:JsonValue + + $Message = "Logz.io logs token is '$ShippingToken'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogsToken = '$ShippingToken'" +} + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-EnableDeployEventsHelmSet { + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building enable deploy events Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:HelmSet = " --set deployEvents.enabled=true" + + $Message = "Enable deploy events Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs listener url Helm set +# Input: +# FuncArgs - Hashtable {ListenerUrl = $script:ListenerUrl} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# HelmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsListenerUrlHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 6 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs listener URL Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('ListenerUrl') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:ListenerUrl = $FuncArgs.ListenerUrl + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioListener=$ListenerUrl" + + $Message = "Logz.io deploy events logs listener url Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# FuncArgs - Hashtable {LogsToken = $script:LogsToken} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-LogzioDeployEventsLogsTokenHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 7 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building Logz.io deploy events logs token Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('LogsToken') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:LogsToken = $FuncArgs.LogsToken + + $local:HelmSet = " --set logzio-k8s-events.secrets.logzioShippingToken=$LogsToken" + + $Message = "Logz.io deploy events logs token Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} + +# Builds Deploy events environment id Helm set +# Input: +# FuncArgs - Hashtable {EnvId = $script:EnvId} +# Output: +# LogHelmSets - Containt all the Helm sets for logging +# helmSets - Contains all the Helm sets +function Build-DeployEventsEnvironmentIdHelmSet { + param ( + [hashtable]$FuncArgs + ) + + $local:ExitCode = 8 + $local:FuncName = $MyInvocation.MyCommand.Name + + $local:Message = 'Building deploy events environment id Helm set ...' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + $local:Err = Test-AreFuncArgsExist $FuncArgs @('EnvId') + if ($Err.Count -ne 0) { + $Message = "logs.ps1 ($ExitCode): $($Err[0])" + Send-LogToLogzio $script:LogLevelError $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-TaskPostRun "Write-Error `"$Message`"" + + return $ExitCode + } + + $local:EnvId = $FuncArgs.EnvId + + if ([string]::IsNullOrEmpty($EnvId)) { + $Message = 'Environment id is empty. Default value will be used' + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + return + } + + $local:HelmSet = " --set logzio-k8s-events.secrets.env_id=$EnvId" + + $Message = "Deploy events Environment id Helm set is '$HelmSet'" + Send-LogToLogzio $script:LogLevelDebug $Message $script:LogStepLogs $script:LogScriptLogs $FuncName $script:AgentId $script:Platform $script:Subtype $script:CurrentDataSource + Write-Log $script:LogLevelDebug $Message + + Write-TaskPostRun "`$script:LogHelmSets += '$HelmSet'" + Write-TaskPostRun "`$script:HelmSets += '$HelmSet'" +} diff --git a/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 new file mode 100755 index 000000000..b212d5482 --- /dev/null +++ b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 @@ -0,0 +1,27 @@ +################################################################################################################################# +##################################################### WINDOWS Logs Script ####################################################### +################################################################################################################################# + +$local:LogsFunctionsScript = "$script:LogzioTempDir\$script:Platform\$script:SubType\$($script:CurrentDataSource.ToLower())\$script:LogsFunctionsFile" + +# Print headline +Write-Host +Write-Host '############' +Write-Host '### ' -NoNewline +Write-Host 'Logs' -ForegroundColor Magenta -NoNewline +Write-Host ' ###' +Write-Host '############' + +# Get Logz.io logs token +Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) +# Build enable security report Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs listener url Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) +# Build Logz.io Deploy events logs token Helm set +Invoke-Task 'Build-LogzioDeployEventsLogsTokenHelmSet' @{LogsToken = $script:LogsToken} 'Building Logz.io deploy events logs token Helm set' @($LogsFunctionsScript) +# Build Deploy events environment id Helm set +Invoke-Task 'Build-DeployEventsEnvironmentIdHelmSet' @{EnvId = $script:EnvId} 'Building Deploy events environment id Helm set' @($LogsFunctionsScript) + +# Finished successfully +Exit 0 diff --git a/resources-linux/k8s/datasource_logs_utils.bash b/resources-linux/k8s/datasource_logs_utils.bash index 6462ae044..d8829a182 100755 --- a/resources-linux/k8s/datasource_logs_utils.bash +++ b/resources-linux/k8s/datasource_logs_utils.bash @@ -187,3 +187,95 @@ function build_trivy_environment_id_helm_set { write_task_post_run "LOG_HELM_SETS+='$helm_set'" write_task_post_run "HELM_SETS+='$helm_set'" } + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_enable_deploy_events_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building enable deploy events Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set deployEvents.enabled=true" + + message="Enable deploy events Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds Logz.io deploy events logs listener URL Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_logzio_deploy_events_logs_listener_url_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building Logz.io deploy events logs listener url Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.logzioListener=$LISTENER_URL" + + message="Logz.io deploy events logs listener url Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_logzio_deploy_events_logs_token_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building Logz.io deploy events logs token Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.logzioShippingToken=$LOGS_TOKEN" + + message="Logz.io deploy events logs token Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds deploy events environment id helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_deploy_events_environment_id_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building deploy events environment id Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.env_id=$ENV_ID" + + message="Deploy events environment id Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} diff --git a/resources-mac/k8s/datasource_logs_utils.bash b/resources-mac/k8s/datasource_logs_utils.bash index e3b78686e..f9f12e892 100755 --- a/resources-mac/k8s/datasource_logs_utils.bash +++ b/resources-mac/k8s/datasource_logs_utils.bash @@ -187,3 +187,95 @@ function build_trivy_environment_id_helm_set { write_task_post_run "LOG_HELM_SETS+='$helm_set'" write_task_post_run "HELM_SETS+='$helm_set'" } + +# Builds enable deploy events Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_enable_deploy_events_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building enable deploy events Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set deployEvents.enabled=true" + + message="Enable deploy events Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds Logz.io deploy events logs listener URL Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_logzio_deploy_events_logs_listener_url_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building Logz.io deploy events logs listener url Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.logzioListener=$LISTENER_URL" + + message="Logz.io deploy events logs listener url Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds Logz.io deploy events logs token Helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_logzio_deploy_events_logs_token_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building Logz.io deploy events logs token Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.logzioShippingToken=$LOGS_TOKEN" + + message="Logz.io deploy events logs token Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} + +# Builds deploy events environment id helm set +# Input: +# --- +# Output: +# LOG_HELM_SETS - Contains all the Helm sets for logging +# HELM_SETS - Contains all the Helm sets +function build_deploy_events_environment_id_helm_set { + local func_name="${FUNCNAME[0]}" + + local message='Building deploy events environment id Helm set ...' + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + local helm_set=" --set logzio-k8s-events.secrets.env_id=$ENV_ID" + + message="Deploy events environment id Helm set is '$helm_set'" + send_log_to_logzio "$LOG_LEVEL_DEBUG" "$message" "$LOG_STEP_LOGS" "$LOG_SCRIPT_LOGS" "$func_name" "$AGENT_ID" "$PLATFORM" "$SUB_TYPE" "$CURRENT_DATA_SOURCE" + write_log "$LOG_LEVEL_DEBUG" "$message" + + write_task_post_run "LOG_HELM_SETS+='$helm_set'" + write_task_post_run "HELM_SETS+='$helm_set'" +} From 9b5c72a4eab1fbc5a0b181345428158446f27cb1 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 19:00:55 +0200 Subject: [PATCH 07/14] Update datasource name --- config-templates/helm.json | 4 ++-- configs/2-3-k8s-gke.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index 8b707fe05..ab5168685 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='DeployEvents')]", + "targetElement": "datasources[?(@.name=='Deploy Events')]", "conditionalTemplates": [ { "template": " --set logzio-k8s-events.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", + "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index bae00bc24..384f882d2 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -108,7 +108,7 @@ ] }, { - "name": "DeployEvents", + "name": "Deploy Events", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", From 4b170c728b9298bba097028d3711c0d43896be83 Mon Sep 17 00:00:00 2001 From: ralongit Date: Tue, 7 Nov 2023 19:07:30 +0200 Subject: [PATCH 08/14] Update helm.json --- config-templates/helm.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index ab5168685..cdaf825ac 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -126,7 +126,7 @@ "targetElement": "datasources[?(@.name=='Deploy Events')]", "conditionalTemplates": [ { - "template": " --set logzio-k8s-events.env_id='{{value}}' \\", + "template": " --set logzio-k8s-events.secrets.env_id='{{value}}' \\", "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, From 76fe4e69c07830b6fde3954098374333bab4081e Mon Sep 17 00:00:00 2001 From: ralongit Date: Wed, 8 Nov 2023 13:52:23 +0200 Subject: [PATCH 09/14] Fix name --- config-templates/helm.json | 6 +++--- configs/2-3-k8s-gke.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index cdaf825ac..8b707fe05 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -123,11 +123,11 @@ }, { "template": " --set deployEvents.enabled=true \\", - "targetElement": "datasources[?(@.name=='Deploy Events')]", + "targetElement": "datasources[?(@.name=='DeployEvents')]", "conditionalTemplates": [ { - "template": " --set logzio-k8s-events.secrets.env_id='{{value}}' \\", - "targetElement": "datasources[?(@.name=='Deploy Events')].params[?(@.name=='envID')].value", + "template": " --set logzio-k8s-events.env_id='{{value}}' \\", + "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, { diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 384f882d2..bae00bc24 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -108,7 +108,7 @@ ] }, { - "name": "Deploy Events", + "name": "DeployEvents", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", From fd5d4046cba2114ca17224665cc415e45c6c1e29 Mon Sep 17 00:00:00 2001 From: ralongit Date: Wed, 8 Nov 2023 13:57:30 +0200 Subject: [PATCH 10/14] Remove space from name & fix env_id --- config-templates/helm.json | 2 +- configs/2-1-k8s-eks.json | 2 +- configs/2-2-k8s-aks.json | 2 +- configs/2-4-k8s-digitalocean.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config-templates/helm.json b/config-templates/helm.json index 8b707fe05..01ed8362c 100644 --- a/config-templates/helm.json +++ b/config-templates/helm.json @@ -126,7 +126,7 @@ "targetElement": "datasources[?(@.name=='DeployEvents')]", "conditionalTemplates": [ { - "template": " --set logzio-k8s-events.env_id='{{value}}' \\", + "template": " --set logzio-k8s-events.secrets.env_id='{{value}}' \\", "targetElement": "datasources[?(@.name=='DeployEvents')].params[?(@.name=='envID')].value", "keepAsPlaceholder": true }, diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index 4eb4f9f04..75d5af4ef 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -116,7 +116,7 @@ ] }, { - "name": "Deploy Events", + "name": "DeployEvents", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index 923f3a453..480f8e6fc 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -110,7 +110,7 @@ ] }, { - "name": "Deploy Events", + "name": "DeployEvents", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index f0d7924b6..f791d0b49 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -108,7 +108,7 @@ ] }, { - "name": "Deploy Events", + "name": "DeployEvents", "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", From 1f28369f0fb5f244781245bbdab731dde92360e5 Mon Sep 17 00:00:00 2001 From: ralongit Date: Mon, 13 Nov 2023 12:03:54 +0200 Subject: [PATCH 11/14] Update staging --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e943f856b..1908a51db 100644 --- a/README.md +++ b/README.md @@ -147,3 +147,4 @@ bash <(curl -sSL https://github.com/logzio/logzio-agent-manifest/releases/downlo ```PowerShell powershell { iex “& { $(irm https://github.com/logzio/logzio-agent-manifest/releases/download/latest/run_prerequisites_windows.ps1) } --path=LOGZIO_REPO_DATASOURCE_PATH” } ``` + From 5627887b8d73f485eb3bca580c3e410026ea46af Mon Sep 17 00:00:00 2001 From: ralongit Date: Sun, 19 Nov 2023 15:22:26 +0200 Subject: [PATCH 12/14] Update Kubernetes icons - Updated security logo - Updated deploy events logo - update K8s logo --- configs/2-1-k8s-eks.json | 8 ++++---- configs/2-2-k8s-aks.json | 10 +++++----- configs/2-3-k8s-gke.json | 8 ++++---- configs/2-4-k8s-digitalocean.json | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index f5d9a1dd7..aa162dc6f 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -94,7 +94,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -119,7 +119,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index b584a74a4..600d16bc8 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "", "manifest": true, @@ -17,7 +17,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "Logz.io Uses OpenTelemetry and Fluentd with Helm charts to deploy and monitor Kubernetes architecture", "params": [ @@ -88,7 +88,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -113,7 +113,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ @@ -135,7 +135,7 @@ "params": [] } ] - } + } ] } ] diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index 40cef508b..16a68b7f2 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -86,7 +86,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -111,7 +111,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index 4aff8f143..0eb5bedd8 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -86,7 +86,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -111,7 +111,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ From 7eb533d003d60c2b2b7d8dbcf0607298b5d3c8af Mon Sep 17 00:00:00 2001 From: ralongit Date: Sun, 19 Nov 2023 15:32:56 +0200 Subject: [PATCH 13/14] Fix security typos copy-paste Replace security report with deploy events text as it was copied and not updated. --- .../kubernetes/aks/deployevents/telemetry/logs/logs.ps1 | 4 ++-- .../digitalocean/deployevents/telemetry/logs/logs.ps1 | 4 ++-- .../kubernetes/eks/deployevents/telemetry/logs/logs.ps1 | 4 ++-- .../kubernetes/gke/deployevents/installer/installer.ps1 | 2 +- .../kubernetes/gke/deployevents/telemetry/logs/logs.ps1 | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 index b212d5482..d21431094 100755 --- a/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 +++ b/datasources/windows/kubernetes/aks/deployevents/telemetry/logs/logs.ps1 @@ -14,8 +14,8 @@ Write-Host '############' # Get Logz.io logs token Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) -# Build enable security report Helm set -Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build enable deploy events Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable deploy events Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs listener url Helm set Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs token Helm set diff --git a/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 index b212d5482..d21431094 100755 --- a/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 +++ b/datasources/windows/kubernetes/digitalocean/deployevents/telemetry/logs/logs.ps1 @@ -14,8 +14,8 @@ Write-Host '############' # Get Logz.io logs token Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) -# Build enable security report Helm set -Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build enable deploy events Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable deploy events Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs listener url Helm set Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs token Helm set diff --git a/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 index b212d5482..d21431094 100755 --- a/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 +++ b/datasources/windows/kubernetes/eks/deployevents/telemetry/logs/logs.ps1 @@ -14,8 +14,8 @@ Write-Host '############' # Get Logz.io logs token Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) -# Build enable security report Helm set -Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build enable deploy events Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable deploy events Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs listener url Helm set Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs token Helm set diff --git a/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 b/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 index c69b0ca19..4d2d33191 100755 --- a/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 +++ b/datasources/windows/kubernetes/gke/deployevents/installer/installer.ps1 @@ -38,7 +38,7 @@ $local:InstallerFunctionsScript = "$script:LogzioTempDir\$script:Platform\$scrip Write-Host Write-Host '##########################################' Write-Host '### ' -NoNewline -Write-Host 'Security Datasource Installation' -ForegroundColor Magenta -NoNewline +Write-Host 'Deploy Events Datasource Installation' -ForegroundColor Magenta -NoNewline Write-Host ' ###' Write-Host '##########################################' diff --git a/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 index b212d5482..d21431094 100755 --- a/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 +++ b/datasources/windows/kubernetes/gke/deployevents/telemetry/logs/logs.ps1 @@ -14,8 +14,8 @@ Write-Host '############' # Get Logz.io logs token Invoke-Task 'Get-LogzioLogsToken' @{} 'Getting Logz.io logs token' @($LogsFunctionsScript) -# Build enable security report Helm set -Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable security report Helm set' @($LogsFunctionsScript) +# Build enable deploy events Helm set +Invoke-Task 'Build-EnableDeployEventsHelmSet' @{} 'Building enable deploy events Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs listener url Helm set Invoke-Task 'Build-LogzioDeployEventsLogsListenerUrlHelmSet' @{ListenerUrl = $script:ListenerUrl} 'Building Logz.io deploy events logs listener url Helm set' @($LogsFunctionsScript) # Build Logz.io Deploy events logs token Helm set From d351c74bc99304eb0f7bd43cb9beedefadd43a3b Mon Sep 17 00:00:00 2001 From: ralongit Date: Mon, 4 Dec 2023 15:57:58 +0200 Subject: [PATCH 14/14] Revert icons --- configs/2-1-k8s-eks.json | 8 ++++---- configs/2-2-k8s-aks.json | 8 ++++---- configs/2-3-k8s-gke.json | 8 ++++---- configs/2-4-k8s-digitalocean.json | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/configs/2-1-k8s-eks.json b/configs/2-1-k8s-eks.json index ce5380ef8..b4a876715 100644 --- a/configs/2-1-k8s-eks.json +++ b/configs/2-1-k8s-eks.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -94,7 +94,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -119,7 +119,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ diff --git a/configs/2-2-k8s-aks.json b/configs/2-2-k8s-aks.json index 0a42c1a60..df7dfbb84 100644 --- a/configs/2-2-k8s-aks.json +++ b/configs/2-2-k8s-aks.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "", "manifest": true, @@ -17,7 +17,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "Logz.io Uses OpenTelemetry and Fluentd with Helm charts to deploy and monitor Kubernetes architecture", "params": [ @@ -88,7 +88,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -113,7 +113,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ diff --git a/configs/2-3-k8s-gke.json b/configs/2-3-k8s-gke.json index abd49d1b9..26e2b8929 100644 --- a/configs/2-3-k8s-gke.json +++ b/configs/2-3-k8s-gke.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -86,7 +86,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -111,7 +111,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [ diff --git a/configs/2-4-k8s-digitalocean.json b/configs/2-4-k8s-digitalocean.json index 546de0fcf..f7e889176 100644 --- a/configs/2-4-k8s-digitalocean.json +++ b/configs/2-4-k8s-digitalocean.json @@ -1,6 +1,6 @@ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "", "hint": "Select the environment where you want to deploy Logz.io Telemetry Collector.", @@ -19,7 +19,7 @@ "datasources": [ { "name": "Kubernetes", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kub.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Kubernetes", "description": "Logz.io uses OpenTelemetry instrumentation with Fluentd and Helm charts to deploy and monitor Kubernetes architecture.", "hint": "Select the type of data you'd like to ship: logs, metrics, and traces.", @@ -86,7 +86,7 @@ }, { "name": "Security", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/lock.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/logz_security.png", "label": "Security", "description": "Logz.io Uses Trivy to scan the Kubernetes cluster and collects the security risks reports from each pod", "params": [ @@ -111,7 +111,7 @@ }, { "name": "DeployEvents", - "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/flag.svg", + "logo": "https://dytvr9ot2sszz.cloudfront.net/logz-docs/shipper-logos/kubernetes.svg", "label": "Deploy Events", "description": "Logz.io uses Kubernetes official SDK to detect deploy events that occur in your cluster and allows you to view the changes.", "params": [