From 06c621c6635f166304f18cf490e5934325887c9d Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Thu, 23 Sep 2021 11:00:27 -0700 Subject: [PATCH 01/13] First cut at an implementation --- build/linux/installer/conf/out_oms.conf | 1 + build/windows/installer/conf/out_oms.conf | 1 + kubernetes/omsagent-adx-secret.yml | 3 ++- source/plugins/go/src/oms.go | 18 ++++++++++++++++++ source/plugins/go/src/utils.go | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build/linux/installer/conf/out_oms.conf b/build/linux/installer/conf/out_oms.conf index 21dc4c1ed..bd0287b3f 100644 --- a/build/linux/installer/conf/out_oms.conf +++ b/build/linux/installer/conf/out_oms.conf @@ -3,6 +3,7 @@ adx_cluster_uri_path=/etc/config/settings/adx/ADXCLUSTERURI adx_client_id_path=/etc/config/settings/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/settings/adx/ADXTENANTID adx_client_secret_path=/etc/config/settings/adx/ADXCLIENTSECRET +adx_database_name_path=/etc/config/settings/adx/ADXDATABASENAME cert_file_path=/etc/mdsd.d/oms/%s/oms.crt key_file_path=/etc/mdsd.d/oms/%s/oms.key container_host_file_path=/var/opt/microsoft/docker-cimprov/state/containerhostname diff --git a/build/windows/installer/conf/out_oms.conf b/build/windows/installer/conf/out_oms.conf index 32718616e..958eab3ae 100644 --- a/build/windows/installer/conf/out_oms.conf +++ b/build/windows/installer/conf/out_oms.conf @@ -4,4 +4,5 @@ adx_cluster_uri_path=/etc/config/adx/ADXCLUSTERURI adx_client_id_path=/etc/config/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/adx/ADXTENANTID adx_client_secret_path=/etc/config/adx/ADXCLIENTSECRET +adx_database_name_path=/etc/config/adx/ADXDATABASENAME container_inventory_refresh_interval=60 \ No newline at end of file diff --git a/kubernetes/omsagent-adx-secret.yml b/kubernetes/omsagent-adx-secret.yml index 7fb20826a..b706a7a6e 100644 --- a/kubernetes/omsagent-adx-secret.yml +++ b/kubernetes/omsagent-adx-secret.yml @@ -9,4 +9,5 @@ data: ADXCLUSTERURI: "" ADXCLIENTID: "" ADXTENANTID: "" - ADXCLIENTSECRET: "" \ No newline at end of file + ADXCLIENTSECRET: "" + ADXDATABASENAME: "" \ No newline at end of file diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index 91a5b4b40..9967968ad 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -117,6 +117,9 @@ const MdsdOutputStreamIdTagPrefix = "dcr-" //env variable to container type const ContainerTypeEnv = "CONTAINER_TYPE" +//Default ADX destination database name, can be overriden through configuration +const DefaultAdxDatabaseName = "containerinsights" + var ( // PluginConfiguration the plugins configuration PluginConfiguration map[string]string @@ -166,6 +169,8 @@ var ( AdxTenantID string //ADX client secret AdxClientSecret string + //ADX destination database name, default is DefaultAdxDatabaseName, can be overridden in configuration + AdxDatabaseName string // container log or container log v2 tag name for oneagent route MdsdContainerLogTagName string // kubemonagent events tag name for oneagent route @@ -1723,6 +1728,19 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Error when reading AdxClientSecret %s", err) } + // Try to read the ADX database name from config. Default to DefaultAdsDatabaseName if not set + AdxDatabaseName, err = ReadFileContents(PluginConfiguration["adx_database_name_path"]) + if err != nil { + Log("No database name provided (err %s), will default to '%s'", err, DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + + // Check the len of the provided name for database and use default if 0, just to be sure + if len(AdxDatabaseName) == 0 { + Log("Adx database name unexpecedly empty (check config?) - will default to '%s'", DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 { ContainerLogsRouteADX = true Log("Routing container logs thru %s route...", ContainerLogsADXRoute) diff --git a/source/plugins/go/src/utils.go b/source/plugins/go/src/utils.go index 6b3036f85..61c6898d7 100644 --- a/source/plugins/go/src/utils.go +++ b/source/plugins/go/src/utils.go @@ -192,7 +192,7 @@ func CreateADXClient() { //log.Fatalf("Unable to create ADX connection %s", err.Error()) } else { Log("Successfully created ADX Client. Creating Ingestor...") - ingestor, ingestorErr := ingest.New(client, "containerinsights", "ContainerLogV2") + ingestor, ingestorErr := ingest.New(client, AdxDatabaseName, "ContainerLogV2") if ingestorErr != nil { Log("Error::mdsd::Unable to create ADX ingestor %s", ingestorErr.Error()) } else { From f1b7d825fe007591965146237be264f71d2e6fc4 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Thu, 23 Sep 2021 11:14:43 -0700 Subject: [PATCH 02/13] Reverting a change --- kubernetes/omsagent-adx-secret.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kubernetes/omsagent-adx-secret.yml b/kubernetes/omsagent-adx-secret.yml index b706a7a6e..7fb20826a 100644 --- a/kubernetes/omsagent-adx-secret.yml +++ b/kubernetes/omsagent-adx-secret.yml @@ -9,5 +9,4 @@ data: ADXCLUSTERURI: "" ADXCLIENTID: "" ADXTENANTID: "" - ADXCLIENTSECRET: "" - ADXDATABASENAME: "" \ No newline at end of file + ADXCLIENTSECRET: "" \ No newline at end of file From d33cdb051236301d14c0ce7f560d269b78a2e99e Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Thu, 23 Sep 2021 11:17:14 -0700 Subject: [PATCH 03/13] Moving a few lines to better align with cluster URI config --- build/linux/installer/conf/out_oms.conf | 2 +- build/windows/installer/conf/out_oms.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/linux/installer/conf/out_oms.conf b/build/linux/installer/conf/out_oms.conf index bd0287b3f..4b69fc335 100644 --- a/build/linux/installer/conf/out_oms.conf +++ b/build/linux/installer/conf/out_oms.conf @@ -1,9 +1,9 @@ omsproxy_secret_path=/etc/omsagent-secret/PROXY adx_cluster_uri_path=/etc/config/settings/adx/ADXCLUSTERURI +adx_database_name_path=/etc/config/settings/adx/ADXDATABASENAME adx_client_id_path=/etc/config/settings/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/settings/adx/ADXTENANTID adx_client_secret_path=/etc/config/settings/adx/ADXCLIENTSECRET -adx_database_name_path=/etc/config/settings/adx/ADXDATABASENAME cert_file_path=/etc/mdsd.d/oms/%s/oms.crt key_file_path=/etc/mdsd.d/oms/%s/oms.key container_host_file_path=/var/opt/microsoft/docker-cimprov/state/containerhostname diff --git a/build/windows/installer/conf/out_oms.conf b/build/windows/installer/conf/out_oms.conf index 958eab3ae..5ec931f0c 100644 --- a/build/windows/installer/conf/out_oms.conf +++ b/build/windows/installer/conf/out_oms.conf @@ -1,8 +1,8 @@ cert_file_path=/oms.crt key_file_path=/oms.key adx_cluster_uri_path=/etc/config/adx/ADXCLUSTERURI +adx_database_name_path=/etc/config/adx/ADXDATABASENAME adx_client_id_path=/etc/config/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/adx/ADXTENANTID adx_client_secret_path=/etc/config/adx/ADXCLIENTSECRET -adx_database_name_path=/etc/config/adx/ADXDATABASENAME container_inventory_refresh_interval=60 \ No newline at end of file From b49d1289180b9856785b499b3e3f39768b1904c4 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Thu, 23 Sep 2021 11:19:38 -0700 Subject: [PATCH 04/13] Moving a few lines to better align with cluster URI config --- source/plugins/go/src/oms.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index 9967968ad..1ee8fc903 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -1704,6 +1704,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { //check if adx clusteruri, clientid & secret are set + //also check if default database name is overriden through config var err error AdxClusterUri, err = ReadFileContents(PluginConfiguration["adx_cluster_uri_path"]) if err != nil { @@ -1713,6 +1714,20 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Invalid AdxClusterUri %s", AdxClusterUri) AdxClusterUri = "" } + + // Try to read the ADX database name from config. Default to DefaultAdsDatabaseName if not set + AdxDatabaseName, err = ReadFileContents(PluginConfiguration["adx_database_name_path"]) + if err != nil { + Log("No database name provided (err %s), will default to '%s'", err, DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + + // Check the len of the provided name for database and use default if 0, just to be sure + if len(AdxDatabaseName) == 0 { + Log("Adx database name unexpecedly empty (check config?) - will default to '%s'", DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + AdxClientID, err = ReadFileContents(PluginConfiguration["adx_client_id_path"]) if err != nil { Log("Error when reading AdxClientID %s", err) @@ -1728,19 +1743,6 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Error when reading AdxClientSecret %s", err) } - // Try to read the ADX database name from config. Default to DefaultAdsDatabaseName if not set - AdxDatabaseName, err = ReadFileContents(PluginConfiguration["adx_database_name_path"]) - if err != nil { - Log("No database name provided (err %s), will default to '%s'", err, DefaultAdxDatabaseName) - AdxDatabaseName = DefaultAdxDatabaseName - } - - // Check the len of the provided name for database and use default if 0, just to be sure - if len(AdxDatabaseName) == 0 { - Log("Adx database name unexpecedly empty (check config?) - will default to '%s'", DefaultAdxDatabaseName) - AdxDatabaseName = DefaultAdxDatabaseName - } - if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 { ContainerLogsRouteADX = true Log("Routing container logs thru %s route...", ContainerLogsADXRoute) From 4d50ecf4b9d34f5e57d516b4518eb02f40599fd1 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Thu, 23 Sep 2021 11:21:15 -0700 Subject: [PATCH 05/13] Adding an extra check that won't hurt --- source/plugins/go/src/oms.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index 1ee8fc903..c720f497d 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -1743,7 +1743,8 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Error when reading AdxClientSecret %s", err) } - if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 { + // AdxDatabaseName should never get in a state where its length is 0, but it doesn't hurt to add the check + if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 && len(AdxDatabaseName) == 0 { ContainerLogsRouteADX = true Log("Routing container logs thru %s route...", ContainerLogsADXRoute) fmt.Fprintf(os.Stdout, "Routing container logs thru %s route...\n", ContainerLogsADXRoute) From c5671d7373d5b228e826f16960d97d051685d643 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Wed, 29 Sep 2021 08:15:39 -0700 Subject: [PATCH 06/13] Getting ADX database name from config rather than from secret --- build/common/installer/scripts/tomlparser.rb | 16 + build/linux/installer/conf/out_oms.conf | 1 - build/windows/installer/conf/out_oms.conf | 1 - source/plugins/go/src/oms.go | 295 +++++++++---------- 4 files changed, 163 insertions(+), 150 deletions(-) diff --git a/build/common/installer/scripts/tomlparser.rb b/build/common/installer/scripts/tomlparser.rb index b173ecfe3..4207a523a 100644 --- a/build/common/installer/scripts/tomlparser.rb +++ b/build/common/installer/scripts/tomlparser.rb @@ -26,6 +26,7 @@ @containerLogSchemaVersion = "" @collectAllKubeEvents = false @containerLogsRoute = "v2" # default for linux +@adxDatabaseName = "containerinsights" # default for all configurations if !@os_type.nil? && !@os_type.empty? && @os_type.strip.casecmp("windows") == 0 @containerLogsRoute = "v1" # default is v1 for windows until windows agent integrates windows ama end @@ -175,6 +176,20 @@ def populateSettingValuesFromConfigMap(parsedConfig) ConfigParseErrorLogger.logError("Exception while reading config map settings for container logs route - #{errorStr}, using defaults, please check config map for errors") end + #Get ADX database name setting + begin + if !parsedConfig[:adx_settings][:database_name].nil? + if !parsedConfig[:adx_settings][:database_name].empty? + @adxDatabaseName = parsedConfig[:adx_settings][:database_name] + puts "config::Using config map setting for ADX database name : #{@adxDatabaseName}" + else + puts "config::Ignoring config map settings and using default value since provided adx database name value is empty" + end + end + rescue => errorStr + ConfigParseErrorLogger.logError("Exception while reading config map settings for adx database name - #{errorStr}, using default #{@adxDatabaseName}, please check config map for errors") + end + end end @@ -218,6 +233,7 @@ def populateSettingValuesFromConfigMap(parsedConfig) file.write("export AZMON_CLUSTER_COLLECT_ALL_KUBE_EVENTS=#{@collectAllKubeEvents}\n") file.write("export AZMON_CONTAINER_LOGS_ROUTE=#{@containerLogsRoute}\n") file.write("export AZMON_CONTAINER_LOG_SCHEMA_VERSION=#{@containerLogSchemaVersion}\n") + file.write("export AZMON_ADX_DATABASE_NAME=#{@adxDatabaseName}\n") # Close file after writing all environment variables file.close puts "Both stdout & stderr log collection are turned off for namespaces: '#{@excludePath}' " diff --git a/build/linux/installer/conf/out_oms.conf b/build/linux/installer/conf/out_oms.conf index 4b69fc335..21dc4c1ed 100644 --- a/build/linux/installer/conf/out_oms.conf +++ b/build/linux/installer/conf/out_oms.conf @@ -1,6 +1,5 @@ omsproxy_secret_path=/etc/omsagent-secret/PROXY adx_cluster_uri_path=/etc/config/settings/adx/ADXCLUSTERURI -adx_database_name_path=/etc/config/settings/adx/ADXDATABASENAME adx_client_id_path=/etc/config/settings/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/settings/adx/ADXTENANTID adx_client_secret_path=/etc/config/settings/adx/ADXCLIENTSECRET diff --git a/build/windows/installer/conf/out_oms.conf b/build/windows/installer/conf/out_oms.conf index 5ec931f0c..32718616e 100644 --- a/build/windows/installer/conf/out_oms.conf +++ b/build/windows/installer/conf/out_oms.conf @@ -1,7 +1,6 @@ cert_file_path=/oms.crt key_file_path=/oms.key adx_cluster_uri_path=/etc/config/adx/ADXCLUSTERURI -adx_database_name_path=/etc/config/adx/ADXDATABASENAME adx_client_id_path=/etc/config/adx/ADXCLIENTID adx_tenant_id_path=/etc/config/adx/ADXTENANTID adx_client_secret_path=/etc/config/adx/ADXCLIENTSECRET diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index c720f497d..b5a7a08ce 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -21,9 +21,10 @@ import ( "github.com/google/uuid" "github.com/tinylib/msgp/msgp" - lumberjack "gopkg.in/natefinch/lumberjack.v2" "Docker-Provider/source/plugins/go/src/extension" + lumberjack "gopkg.in/natefinch/lumberjack.v2" + "github.com/Azure/azure-kusto-go/kusto/ingest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -85,7 +86,6 @@ const WindowsContainerLogPluginConfFilePath = "/etc/omsagentwindows/out_oms.conf // IPName const IPName = "ContainerInsights" - const defaultContainerInventoryRefreshInterval = 60 const kubeMonAgentConfigEventFlushInterval = 60 @@ -252,29 +252,29 @@ type DataItemLAv1 struct { // DataItemLAv2 == ContainerLogV2 table in LA // Please keep the names same as destination column names, to avoid transforming one to another in the pipeline type DataItemLAv2 struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` } // DataItemADX == ContainerLogV2 table in ADX type DataItemADX struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` - AzureResourceId string `json:"AzureResourceId"` + AzureResourceId string `json:"AzureResourceId"` } // telegraf metric DataItem represents the object corresponding to the json that is sent by fluentbit tail plugin @@ -299,15 +299,15 @@ type InsightsMetricsBlob struct { // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv1 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv1 `json:"DataItems"` } // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv2 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv2 `json:"DataItems"` } @@ -361,6 +361,7 @@ const ( // DataType to be used as enum per data type socket client creation type DataType int + const ( // DataType to be used as enum per data type socket client creation ContainerLogV2 DataType = iota @@ -628,12 +629,12 @@ func flushKubeMonAgentEventRecords() { Log(message) SendException(message) } else { - msgPackEntry := MsgPackEntry{ + msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } + } } } @@ -670,8 +671,8 @@ func flushKubeMonAgentEventRecords() { msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } } } } @@ -713,18 +714,18 @@ func flushKubeMonAgentEventRecords() { } else { if err := json.Unmarshal(jsonBytes, &stringMap); err != nil { message := fmt.Sprintf("Error while UnMarshalling json bytes to stringmap: %s", err.Error()) - Log(message) - SendException(message) + Log(message) + SendException(message) } else { msgPackEntry := MsgPackEntry{ Record: stringMap, - } - msgPackEntries = append(msgPackEntries, msgPackEntry) + } + msgPackEntries = append(msgPackEntries, msgPackEntry) } } } } - if (IsWindows == false && len(msgPackEntries) > 0) { //for linux, mdsd route + if IsWindows == false && len(msgPackEntries) > 0 { //for linux, mdsd route if IsAADMSIAuthMode == true && strings.HasPrefix(MdsdKubeMonAgentEventsTagName, MdsdOutputStreamIdTagPrefix) == false { Log("Info::mdsd::obtaining output stream id for data type: %s", KubeMonAgentEventDataType) MdsdKubeMonAgentEventsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(KubeMonAgentEventDataType) @@ -757,7 +758,7 @@ func flushKubeMonAgentEventRecords() { } else { numRecords := len(msgPackEntries) Log("FlushKubeMonAgentEventRecords::Info::Successfully flushed %d records that was %d bytes in %s", numRecords, bts, elapsed) - // Send telemetry to AppInsights resource + // Send telemetry to AppInsights resource SendEvent(KubeMonAgentEventsFlushedEvent, telemetryDimensions) } } else { @@ -788,8 +789,8 @@ func flushKubeMonAgentEventRecords() { if IsAADMSIAuthMode == true { IngestionAuthTokenUpdateMutex.Lock() - ingestionAuthToken := ODSIngestionAuthToken - IngestionAuthTokenUpdateMutex.Unlock() + ingestionAuthToken := ODSIngestionAuthToken + IngestionAuthTokenUpdateMutex.Unlock() if ingestionAuthToken == "" { Log("Error::ODS Ingestion Auth Token is empty. Please check error log.") } @@ -910,77 +911,77 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int var msgPackEntries []MsgPackEntry var i int start := time.Now() - var elapsed time.Duration + var elapsed time.Duration for i = 0; i < len(laMetrics); i++ { - var interfaceMap map[string]interface{} - stringMap := make(map[string]string) - jsonBytes, err := json.Marshal(*laMetrics[i]) - if err != nil { - message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) + var interfaceMap map[string]interface{} + stringMap := make(map[string]string) + jsonBytes, err := json.Marshal(*laMetrics[i]) + if err != nil { + message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) + Log(message) + SendException(message) + return output.FLB_OK + } else { + if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { + message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) Log(message) SendException(message) return output.FLB_OK } else { - if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { - message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) - Log(message) - SendException(message) - return output.FLB_OK - } else { - for key, value := range interfaceMap { - strKey := fmt.Sprintf("%v", key) - strValue := fmt.Sprintf("%v", value) - stringMap[strKey] = strValue - } - msgPackEntry := MsgPackEntry{ - Record: stringMap, - } - msgPackEntries = append(msgPackEntries, msgPackEntry) + for key, value := range interfaceMap { + strKey := fmt.Sprintf("%v", key) + strValue := fmt.Sprintf("%v", value) + stringMap[strKey] = strValue } + msgPackEntry := MsgPackEntry{ + Record: stringMap, + } + msgPackEntries = append(msgPackEntries, msgPackEntry) } + } } - if (len(msgPackEntries) > 0) { - if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { - Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") - MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) - } - msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) + if len(msgPackEntries) > 0 { + if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { + Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") + MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) + } + msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) + if MdsdInsightsMetricsMsgpUnixSocketClient == nil { + Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") + CreateMDSDClient(InsightsMetrics, ContainerType) if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") - CreateMDSDClient(InsightsMetrics, ContainerType) - if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") - ContainerLogTelemetryMutex.Lock() - defer ContainerLogTelemetryMutex.Unlock() - InsightsMetricsMDSDClientCreateErrors += 1 - return output.FLB_RETRY - } - } - - deadline := 10 * time.Second - MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse - bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) - - elapsed = time.Since(start) - - if er != nil { - Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) - if MdsdInsightsMetricsMsgpUnixSocketClient != nil { - MdsdInsightsMetricsMsgpUnixSocketClient.Close() - MdsdInsightsMetricsMsgpUnixSocketClient = nil - } - + Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") ContainerLogTelemetryMutex.Lock() defer ContainerLogTelemetryMutex.Unlock() InsightsMetricsMDSDClientCreateErrors += 1 return output.FLB_RETRY - } else { - numTelegrafMetricsRecords := len(msgPackEntries) - UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) - Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) } + } + + deadline := 10 * time.Second + MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse + bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) + + elapsed = time.Since(start) + + if er != nil { + Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) + if MdsdInsightsMetricsMsgpUnixSocketClient != nil { + MdsdInsightsMetricsMsgpUnixSocketClient.Close() + MdsdInsightsMetricsMsgpUnixSocketClient = nil + } + + ContainerLogTelemetryMutex.Lock() + defer ContainerLogTelemetryMutex.Unlock() + InsightsMetricsMDSDClientCreateErrors += 1 + return output.FLB_RETRY + } else { + numTelegrafMetricsRecords := len(msgPackEntries) + UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) + Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) + } } } else { // for windows, ODS direct @@ -1117,12 +1118,12 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap = make(map[string]string) //below id & name are used by latency telemetry in both v1 & v2 LA schemas id := "" - name := "" + name := "" logEntry := ToString(record["log"]) logEntryTimeStamp := ToString(record["time"]) //ADX Schema & LAv2 schema are almost the same (except resourceId) - if (ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true) { + if ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true { stringMap["Computer"] = Computer stringMap["ContainerId"] = containerID stringMap["ContainerName"] = containerName @@ -1171,29 +1172,29 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap["AzureResourceId"] = "" } dataItemADX = DataItemADX{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], - AzureResourceId: stringMap["AzureResourceId"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], + AzureResourceId: stringMap["AzureResourceId"], } //ADX dataItemsADX = append(dataItemsADX, dataItemADX) } else { - if (ContainerLogSchemaV2 == true) { + if ContainerLogSchemaV2 == true { dataItemLAv2 = DataItemLAv2{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], } //ODS-v2 schema dataItemsLAv2 = append(dataItemsLAv2, dataItemLAv2) @@ -1211,10 +1212,10 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { Image: stringMap["Image"], Name: stringMap["Name"], } - //ODS-v1 schema - dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) - name = stringMap["Name"] - id = stringMap["Id"] + //ODS-v1 schema + dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) + name = stringMap["Name"] + id = stringMap["Id"] } } @@ -1364,18 +1365,18 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = len(dataItemsADX) Log("Success::ADX::Successfully wrote %d container log records to ADX in %s", numContainerLogRecords, elapsed) - } else if ((ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0) { //ODS + } else if (ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0 { //ODS var logEntry interface{} recordType := "" loglinesCount := 0 //schema v2 - if (len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true) { + if len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true { logEntry = ContainerLogBlobLAv2{ DataType: ContainerLogV2DataType, IPName: IPName, DataItems: dataItemsLAv2} - loglinesCount = len(dataItemsLAv2) - recordType = "ContainerLogV2" + loglinesCount = len(dataItemsLAv2) + recordType = "ContainerLogV2" } else { //schema v1 if len(dataItemsLAv1) > 0 { @@ -1383,8 +1384,8 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { DataType: ContainerLogDataType, IPName: IPName, DataItems: dataItemsLAv1} - loglinesCount = len(dataItemsLAv1) - recordType = "ContainerLog" + loglinesCount = len(dataItemsLAv1) + recordType = "ContainerLog" } } @@ -1416,7 +1417,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { return output.FLB_RETRY } // add authorization header to the req - req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) + req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) } resp, err := HTTPClient.Do(req) @@ -1444,7 +1445,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = loglinesCount Log("PostDataHelper::Info::Successfully flushed %d %s records to ODS in %s", numContainerLogRecords, recordType, elapsed) - } + } ContainerLogTelemetryMutex.Lock() defer ContainerLogTelemetryMutex.Unlock() @@ -1558,7 +1559,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Container Type %s", ContainerType) osType := os.Getenv("OS_TYPE") - IsWindows = false + IsWindows = false // Linux if strings.Compare(strings.ToLower(osType), "windows") != 0 { Log("Reading configuration for Linux from %s", pluginConfPath) @@ -1702,6 +1703,17 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { ContainerLogsRouteV2 = false ContainerLogsRouteADX = false + // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. This SHOULD be set by tomlparser.rb so + // it's a highly unexpected event if it isn't. + // It should be set by the logic in tomlparser.rb EVEN if ADX logging isn't enabled + AdxDatabaseName := strings.TrimSpace(os.Getenv("AZMON_ADX_DATABASE_NAME")) + + // Check the len of the provided name for database and use default if 0, just to be sure + if len(AdxDatabaseName) == 0 { + Log("Adx database name unexpecedly empty (check config AND implementation, should have been set by tomlparser.rb?) - will default to '%s'", DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { //check if adx clusteruri, clientid & secret are set //also check if default database name is overriden through config @@ -1715,19 +1727,6 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { AdxClusterUri = "" } - // Try to read the ADX database name from config. Default to DefaultAdsDatabaseName if not set - AdxDatabaseName, err = ReadFileContents(PluginConfiguration["adx_database_name_path"]) - if err != nil { - Log("No database name provided (err %s), will default to '%s'", err, DefaultAdxDatabaseName) - AdxDatabaseName = DefaultAdxDatabaseName - } - - // Check the len of the provided name for database and use default if 0, just to be sure - if len(AdxDatabaseName) == 0 { - Log("Adx database name unexpecedly empty (check config?) - will default to '%s'", DefaultAdxDatabaseName) - AdxDatabaseName = DefaultAdxDatabaseName - } - AdxClientID, err = ReadFileContents(PluginConfiguration["adx_client_id_path"]) if err != nil { Log("Error when reading AdxClientID %s", err) @@ -1750,9 +1749,9 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { fmt.Fprintf(os.Stdout, "Routing container logs thru %s route...\n", ContainerLogsADXRoute) } } else if strings.Compare(strings.ToLower(osType), "windows") != 0 { //for linux, oneagent will be default route - ContainerLogsRouteV2 = true //default is mdsd route + ContainerLogsRouteV2 = true //default is mdsd route if strings.Compare(ContainerLogsRoute, ContainerLogsV1Route) == 0 { - ContainerLogsRouteV2 = false //fallback option when hiddensetting set + ContainerLogsRouteV2 = false //fallback option when hiddensetting set } Log("Routing container logs thru %s route...", ContainerLogsRoute) fmt.Fprintf(os.Stdout, "Routing container logs thru %s route... \n", ContainerLogsRoute) @@ -1771,14 +1770,14 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Creating MDSD clients for KubeMonAgentEvents & InsightsMetrics") CreateMDSDClient(KubeMonAgentEvents, ContainerType) CreateMDSDClient(InsightsMetrics, ContainerType) - } + } ContainerLogSchemaVersion := strings.TrimSpace(strings.ToLower(os.Getenv("AZMON_CONTAINER_LOG_SCHEMA_VERSION"))) Log("AZMON_CONTAINER_LOG_SCHEMA_VERSION:%s", ContainerLogSchemaVersion) - ContainerLogSchemaV2 = false //default is v1 schema + ContainerLogSchemaV2 = false //default is v1 schema - if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { + if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { ContainerLogSchemaV2 = true Log("Container logs schema=%s", ContainerLogV2SchemaVersion) fmt.Fprintf(os.Stdout, "Container logs schema=%s... \n", ContainerLogV2SchemaVersion) @@ -1804,15 +1803,15 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { if ContainerLogSchemaV2 == true { MdsdContainerLogTagName = MdsdContainerLogV2SourceName } else { - MdsdContainerLogTagName = MdsdContainerLogSourceName - } + MdsdContainerLogTagName = MdsdContainerLogSourceName + } MdsdInsightsMetricsTagName = MdsdInsightsMetricsSourceName - MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName + MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName Log("ContainerLogsRouteADX: %v, IsWindows: %v, IsAADMSIAuthMode = %v \n", ContainerLogsRouteADX, IsWindows, IsAADMSIAuthMode) if !ContainerLogsRouteADX && IsWindows && IsAADMSIAuthMode { Log("defaultIngestionAuthTokenRefreshIntervalSeconds = %d \n", defaultIngestionAuthTokenRefreshIntervalSeconds) - IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) + IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) go refreshIngestionAuthToken() } } From 2ce370f0c5c27a7c227d481630bbfa1718f0f460 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Wed, 29 Sep 2021 08:18:49 -0700 Subject: [PATCH 07/13] Reverse the mangling done by editor --- source/plugins/go/src/oms.go | 274 +++++++++++++++++------------------ 1 file changed, 136 insertions(+), 138 deletions(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index b5a7a08ce..6688125e5 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -21,9 +21,8 @@ import ( "github.com/google/uuid" "github.com/tinylib/msgp/msgp" - "Docker-Provider/source/plugins/go/src/extension" - lumberjack "gopkg.in/natefinch/lumberjack.v2" + "Docker-Provider/source/plugins/go/src/extension" "github.com/Azure/azure-kusto-go/kusto/ingest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -86,6 +85,7 @@ const WindowsContainerLogPluginConfFilePath = "/etc/omsagentwindows/out_oms.conf // IPName const IPName = "ContainerInsights" + const defaultContainerInventoryRefreshInterval = 60 const kubeMonAgentConfigEventFlushInterval = 60 @@ -252,29 +252,29 @@ type DataItemLAv1 struct { // DataItemLAv2 == ContainerLogV2 table in LA // Please keep the names same as destination column names, to avoid transforming one to another in the pipeline type DataItemLAv2 struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` } // DataItemADX == ContainerLogV2 table in ADX type DataItemADX struct { - TimeGenerated string `json:"TimeGenerated"` - Computer string `json:"Computer"` - ContainerId string `json:"ContainerId"` - ContainerName string `json:"ContainerName"` - PodName string `json:"PodName"` - PodNamespace string `json:"PodNamespace"` - LogMessage string `json:"LogMessage"` - LogSource string `json:"LogSource"` + TimeGenerated string `json:"TimeGenerated"` + Computer string `json:"Computer"` + ContainerId string `json:"ContainerId"` + ContainerName string `json:"ContainerName"` + PodName string `json:"PodName"` + PodNamespace string `json:"PodNamespace"` + LogMessage string `json:"LogMessage"` + LogSource string `json:"LogSource"` //PodLabels string `json:"PodLabels"` - AzureResourceId string `json:"AzureResourceId"` + AzureResourceId string `json:"AzureResourceId"` } // telegraf metric DataItem represents the object corresponding to the json that is sent by fluentbit tail plugin @@ -299,15 +299,15 @@ type InsightsMetricsBlob struct { // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv1 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv1 `json:"DataItems"` } // ContainerLogBlob represents the object corresponding to the payload that is sent to the ODS end point type ContainerLogBlobLAv2 struct { - DataType string `json:"DataType"` - IPName string `json:"IPName"` + DataType string `json:"DataType"` + IPName string `json:"IPName"` DataItems []DataItemLAv2 `json:"DataItems"` } @@ -361,7 +361,6 @@ const ( // DataType to be used as enum per data type socket client creation type DataType int - const ( // DataType to be used as enum per data type socket client creation ContainerLogV2 DataType = iota @@ -629,12 +628,12 @@ func flushKubeMonAgentEventRecords() { Log(message) SendException(message) } else { - msgPackEntry := MsgPackEntry{ + msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } + } } } @@ -671,8 +670,8 @@ func flushKubeMonAgentEventRecords() { msgPackEntry := MsgPackEntry{ Record: stringMap, } - msgPackEntries = append(msgPackEntries, msgPackEntry) - } + msgPackEntries = append(msgPackEntries, msgPackEntry) + } } } } @@ -714,18 +713,18 @@ func flushKubeMonAgentEventRecords() { } else { if err := json.Unmarshal(jsonBytes, &stringMap); err != nil { message := fmt.Sprintf("Error while UnMarshalling json bytes to stringmap: %s", err.Error()) - Log(message) - SendException(message) + Log(message) + SendException(message) } else { msgPackEntry := MsgPackEntry{ Record: stringMap, - } - msgPackEntries = append(msgPackEntries, msgPackEntry) + } + msgPackEntries = append(msgPackEntries, msgPackEntry) } } } } - if IsWindows == false && len(msgPackEntries) > 0 { //for linux, mdsd route + if (IsWindows == false && len(msgPackEntries) > 0) { //for linux, mdsd route if IsAADMSIAuthMode == true && strings.HasPrefix(MdsdKubeMonAgentEventsTagName, MdsdOutputStreamIdTagPrefix) == false { Log("Info::mdsd::obtaining output stream id for data type: %s", KubeMonAgentEventDataType) MdsdKubeMonAgentEventsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(KubeMonAgentEventDataType) @@ -758,7 +757,7 @@ func flushKubeMonAgentEventRecords() { } else { numRecords := len(msgPackEntries) Log("FlushKubeMonAgentEventRecords::Info::Successfully flushed %d records that was %d bytes in %s", numRecords, bts, elapsed) - // Send telemetry to AppInsights resource + // Send telemetry to AppInsights resource SendEvent(KubeMonAgentEventsFlushedEvent, telemetryDimensions) } } else { @@ -789,8 +788,8 @@ func flushKubeMonAgentEventRecords() { if IsAADMSIAuthMode == true { IngestionAuthTokenUpdateMutex.Lock() - ingestionAuthToken := ODSIngestionAuthToken - IngestionAuthTokenUpdateMutex.Unlock() + ingestionAuthToken := ODSIngestionAuthToken + IngestionAuthTokenUpdateMutex.Unlock() if ingestionAuthToken == "" { Log("Error::ODS Ingestion Auth Token is empty. Please check error log.") } @@ -911,77 +910,77 @@ func PostTelegrafMetricsToLA(telegrafRecords []map[interface{}]interface{}) int var msgPackEntries []MsgPackEntry var i int start := time.Now() - var elapsed time.Duration + var elapsed time.Duration for i = 0; i < len(laMetrics); i++ { - var interfaceMap map[string]interface{} - stringMap := make(map[string]string) - jsonBytes, err := json.Marshal(*laMetrics[i]) - if err != nil { - message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) - Log(message) - SendException(message) - return output.FLB_OK - } else { - if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { - message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) + var interfaceMap map[string]interface{} + stringMap := make(map[string]string) + jsonBytes, err := json.Marshal(*laMetrics[i]) + if err != nil { + message := fmt.Sprintf("PostTelegrafMetricsToLA::Error:when marshalling json %q", err) Log(message) SendException(message) return output.FLB_OK } else { - for key, value := range interfaceMap { - strKey := fmt.Sprintf("%v", key) - strValue := fmt.Sprintf("%v", value) - stringMap[strKey] = strValue - } - msgPackEntry := MsgPackEntry{ - Record: stringMap, + if err := json.Unmarshal(jsonBytes, &interfaceMap); err != nil { + message := fmt.Sprintf("Error while UnMarshalling json bytes to interfaceMap: %s", err.Error()) + Log(message) + SendException(message) + return output.FLB_OK + } else { + for key, value := range interfaceMap { + strKey := fmt.Sprintf("%v", key) + strValue := fmt.Sprintf("%v", value) + stringMap[strKey] = strValue + } + msgPackEntry := MsgPackEntry{ + Record: stringMap, + } + msgPackEntries = append(msgPackEntries, msgPackEntry) } - msgPackEntries = append(msgPackEntries, msgPackEntry) } - } } - if len(msgPackEntries) > 0 { - if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { - Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") - MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) - } - msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) - if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") - CreateMDSDClient(InsightsMetrics, ContainerType) + if (len(msgPackEntries) > 0) { + if IsAADMSIAuthMode == true && (strings.HasPrefix(MdsdInsightsMetricsTagName, MdsdOutputStreamIdTagPrefix) == false) { + Log("Info::mdsd::obtaining output stream id for InsightsMetricsDataType since Log Analytics AAD MSI Auth Enabled") + MdsdInsightsMetricsTagName = extension.GetInstance(FLBLogger, ContainerType).GetOutputStreamId(InsightsMetricsDataType) + } + msgpBytes := convertMsgPackEntriesToMsgpBytes(MdsdInsightsMetricsTagName, msgPackEntries) if MdsdInsightsMetricsMsgpUnixSocketClient == nil { - Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") - ContainerLogTelemetryMutex.Lock() - defer ContainerLogTelemetryMutex.Unlock() - InsightsMetricsMDSDClientCreateErrors += 1 - return output.FLB_RETRY + Log("Error::mdsd::mdsd connection does not exist. re-connecting ...") + CreateMDSDClient(InsightsMetrics, ContainerType) + if MdsdInsightsMetricsMsgpUnixSocketClient == nil { + Log("Error::mdsd::Unable to create mdsd client for insights metrics. Please check error log.") + ContainerLogTelemetryMutex.Lock() + defer ContainerLogTelemetryMutex.Unlock() + InsightsMetricsMDSDClientCreateErrors += 1 + return output.FLB_RETRY + } } - } - deadline := 10 * time.Second - MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse - bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) + deadline := 10 * time.Second + MdsdInsightsMetricsMsgpUnixSocketClient.SetWriteDeadline(time.Now().Add(deadline)) //this is based of clock time, so cannot reuse + bts, er := MdsdInsightsMetricsMsgpUnixSocketClient.Write(msgpBytes) - elapsed = time.Since(start) + elapsed = time.Since(start) - if er != nil { - Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) - UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) - if MdsdInsightsMetricsMsgpUnixSocketClient != nil { - MdsdInsightsMetricsMsgpUnixSocketClient.Close() - MdsdInsightsMetricsMsgpUnixSocketClient = nil - } + if er != nil { + Log("Error::mdsd::Failed to write to mdsd %d records after %s. Will retry ... error : %s", len(msgPackEntries), elapsed, er.Error()) + UpdateNumTelegrafMetricsSentTelemetry(0, 1, 0) + if MdsdInsightsMetricsMsgpUnixSocketClient != nil { + MdsdInsightsMetricsMsgpUnixSocketClient.Close() + MdsdInsightsMetricsMsgpUnixSocketClient = nil + } - ContainerLogTelemetryMutex.Lock() - defer ContainerLogTelemetryMutex.Unlock() - InsightsMetricsMDSDClientCreateErrors += 1 - return output.FLB_RETRY - } else { - numTelegrafMetricsRecords := len(msgPackEntries) - UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) - Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) - } + ContainerLogTelemetryMutex.Lock() + defer ContainerLogTelemetryMutex.Unlock() + InsightsMetricsMDSDClientCreateErrors += 1 + return output.FLB_RETRY + } else { + numTelegrafMetricsRecords := len(msgPackEntries) + UpdateNumTelegrafMetricsSentTelemetry(numTelegrafMetricsRecords, 0, 0) + Log("Success::mdsd::Successfully flushed %d telegraf metrics records that was %d bytes to mdsd in %s ", numTelegrafMetricsRecords, bts, elapsed) + } } } else { // for windows, ODS direct @@ -1118,12 +1117,12 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap = make(map[string]string) //below id & name are used by latency telemetry in both v1 & v2 LA schemas id := "" - name := "" + name := "" logEntry := ToString(record["log"]) logEntryTimeStamp := ToString(record["time"]) //ADX Schema & LAv2 schema are almost the same (except resourceId) - if ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true { + if (ContainerLogSchemaV2 == true || ContainerLogsRouteADX == true) { stringMap["Computer"] = Computer stringMap["ContainerId"] = containerID stringMap["ContainerName"] = containerName @@ -1172,29 +1171,29 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { stringMap["AzureResourceId"] = "" } dataItemADX = DataItemADX{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], - AzureResourceId: stringMap["AzureResourceId"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], + AzureResourceId: stringMap["AzureResourceId"], } //ADX dataItemsADX = append(dataItemsADX, dataItemADX) } else { - if ContainerLogSchemaV2 == true { + if (ContainerLogSchemaV2 == true) { dataItemLAv2 = DataItemLAv2{ - TimeGenerated: stringMap["TimeGenerated"], - Computer: stringMap["Computer"], - ContainerId: stringMap["ContainerId"], - ContainerName: stringMap["ContainerName"], - PodName: stringMap["PodName"], - PodNamespace: stringMap["PodNamespace"], - LogMessage: stringMap["LogMessage"], - LogSource: stringMap["LogSource"], + TimeGenerated: stringMap["TimeGenerated"], + Computer: stringMap["Computer"], + ContainerId: stringMap["ContainerId"], + ContainerName: stringMap["ContainerName"], + PodName: stringMap["PodName"], + PodNamespace: stringMap["PodNamespace"], + LogMessage: stringMap["LogMessage"], + LogSource: stringMap["LogSource"], } //ODS-v2 schema dataItemsLAv2 = append(dataItemsLAv2, dataItemLAv2) @@ -1212,10 +1211,10 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { Image: stringMap["Image"], Name: stringMap["Name"], } - //ODS-v1 schema - dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) - name = stringMap["Name"] - id = stringMap["Id"] + //ODS-v1 schema + dataItemsLAv1 = append(dataItemsLAv1, dataItemLAv1) + name = stringMap["Name"] + id = stringMap["Id"] } } @@ -1365,18 +1364,18 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = len(dataItemsADX) Log("Success::ADX::Successfully wrote %d container log records to ADX in %s", numContainerLogRecords, elapsed) - } else if (ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0 { //ODS + } else if ((ContainerLogSchemaV2 == true && len(dataItemsLAv2) > 0) || len(dataItemsLAv1) > 0) { //ODS var logEntry interface{} recordType := "" loglinesCount := 0 //schema v2 - if len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true { + if (len(dataItemsLAv2) > 0 && ContainerLogSchemaV2 == true) { logEntry = ContainerLogBlobLAv2{ DataType: ContainerLogV2DataType, IPName: IPName, DataItems: dataItemsLAv2} - loglinesCount = len(dataItemsLAv2) - recordType = "ContainerLogV2" + loglinesCount = len(dataItemsLAv2) + recordType = "ContainerLogV2" } else { //schema v1 if len(dataItemsLAv1) > 0 { @@ -1384,8 +1383,8 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { DataType: ContainerLogDataType, IPName: IPName, DataItems: dataItemsLAv1} - loglinesCount = len(dataItemsLAv1) - recordType = "ContainerLog" + loglinesCount = len(dataItemsLAv1) + recordType = "ContainerLog" } } @@ -1417,7 +1416,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { return output.FLB_RETRY } // add authorization header to the req - req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) + req.Header.Set("Authorization", "Bearer "+ingestionAuthToken) } resp, err := HTTPClient.Do(req) @@ -1445,7 +1444,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { numContainerLogRecords = loglinesCount Log("PostDataHelper::Info::Successfully flushed %d %s records to ODS in %s", numContainerLogRecords, recordType, elapsed) - } + } ContainerLogTelemetryMutex.Lock() defer ContainerLogTelemetryMutex.Unlock() @@ -1559,7 +1558,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Container Type %s", ContainerType) osType := os.Getenv("OS_TYPE") - IsWindows = false + IsWindows = false // Linux if strings.Compare(strings.ToLower(osType), "windows") != 0 { Log("Reading configuration for Linux from %s", pluginConfPath) @@ -1713,10 +1712,9 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Adx database name unexpecedly empty (check config AND implementation, should have been set by tomlparser.rb?) - will default to '%s'", DefaultAdxDatabaseName) AdxDatabaseName = DefaultAdxDatabaseName } - + if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { //check if adx clusteruri, clientid & secret are set - //also check if default database name is overriden through config var err error AdxClusterUri, err = ReadFileContents(PluginConfiguration["adx_cluster_uri_path"]) if err != nil { @@ -1749,9 +1747,9 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { fmt.Fprintf(os.Stdout, "Routing container logs thru %s route...\n", ContainerLogsADXRoute) } } else if strings.Compare(strings.ToLower(osType), "windows") != 0 { //for linux, oneagent will be default route - ContainerLogsRouteV2 = true //default is mdsd route + ContainerLogsRouteV2 = true //default is mdsd route if strings.Compare(ContainerLogsRoute, ContainerLogsV1Route) == 0 { - ContainerLogsRouteV2 = false //fallback option when hiddensetting set + ContainerLogsRouteV2 = false //fallback option when hiddensetting set } Log("Routing container logs thru %s route...", ContainerLogsRoute) fmt.Fprintf(os.Stdout, "Routing container logs thru %s route... \n", ContainerLogsRoute) @@ -1770,14 +1768,14 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { Log("Creating MDSD clients for KubeMonAgentEvents & InsightsMetrics") CreateMDSDClient(KubeMonAgentEvents, ContainerType) CreateMDSDClient(InsightsMetrics, ContainerType) - } + } ContainerLogSchemaVersion := strings.TrimSpace(strings.ToLower(os.Getenv("AZMON_CONTAINER_LOG_SCHEMA_VERSION"))) Log("AZMON_CONTAINER_LOG_SCHEMA_VERSION:%s", ContainerLogSchemaVersion) - ContainerLogSchemaV2 = false //default is v1 schema + ContainerLogSchemaV2 = false //default is v1 schema - if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { + if strings.Compare(ContainerLogSchemaVersion, ContainerLogV2SchemaVersion) == 0 && ContainerLogsRouteADX != true { ContainerLogSchemaV2 = true Log("Container logs schema=%s", ContainerLogV2SchemaVersion) fmt.Fprintf(os.Stdout, "Container logs schema=%s... \n", ContainerLogV2SchemaVersion) @@ -1803,15 +1801,15 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { if ContainerLogSchemaV2 == true { MdsdContainerLogTagName = MdsdContainerLogV2SourceName } else { - MdsdContainerLogTagName = MdsdContainerLogSourceName - } + MdsdContainerLogTagName = MdsdContainerLogSourceName + } MdsdInsightsMetricsTagName = MdsdInsightsMetricsSourceName - MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName + MdsdKubeMonAgentEventsTagName = MdsdKubeMonAgentEventsSourceName Log("ContainerLogsRouteADX: %v, IsWindows: %v, IsAADMSIAuthMode = %v \n", ContainerLogsRouteADX, IsWindows, IsAADMSIAuthMode) if !ContainerLogsRouteADX && IsWindows && IsAADMSIAuthMode { Log("defaultIngestionAuthTokenRefreshIntervalSeconds = %d \n", defaultIngestionAuthTokenRefreshIntervalSeconds) - IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) + IngestionAuthTokenRefreshTicker = time.NewTicker(time.Second * time.Duration(defaultIngestionAuthTokenRefreshIntervalSeconds)) go refreshIngestionAuthToken() } } From 63804cf244f2c61768c71b304b756f2ee8dd738b Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Wed, 29 Sep 2021 11:43:31 -0700 Subject: [PATCH 08/13] Fixes to the code for reading the db name setting --- build/common/installer/scripts/tomlparser.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/common/installer/scripts/tomlparser.rb b/build/common/installer/scripts/tomlparser.rb index 4207a523a..cbfa1e9b3 100644 --- a/build/common/installer/scripts/tomlparser.rb +++ b/build/common/installer/scripts/tomlparser.rb @@ -178,9 +178,9 @@ def populateSettingValuesFromConfigMap(parsedConfig) #Get ADX database name setting begin - if !parsedConfig[:adx_settings][:database_name].nil? - if !parsedConfig[:adx_settings][:database_name].empty? - @adxDatabaseName = parsedConfig[:adx_settings][:database_name] + if !parsedConfig[:log_collection_settings][:adx_database_name].nil? + if !parsedConfig[:log_collection_settings][:adx_database_name].empty? + @adxDatabaseName = parsedConfig[:log_collection_settings][:adx_database_name] puts "config::Using config map setting for ADX database name : #{@adxDatabaseName}" else puts "config::Ignoring config map settings and using default value since provided adx database name value is empty" From cb05383bcac969abdbe2c6619deb7e381f8c8a63 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Wed, 29 Sep 2021 12:02:32 -0700 Subject: [PATCH 09/13] More fixes to the rb code for settings --- build/common/installer/scripts/tomlparser.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/common/installer/scripts/tomlparser.rb b/build/common/installer/scripts/tomlparser.rb index cbfa1e9b3..abc704e84 100644 --- a/build/common/installer/scripts/tomlparser.rb +++ b/build/common/installer/scripts/tomlparser.rb @@ -282,6 +282,8 @@ def get_command_windows(env_variable_name, env_variable_value) file.write(commands) commands = get_command_windows('AZMON_CONTAINER_LOG_SCHEMA_VERSION', @containerLogSchemaVersion) file.write(commands) + commands = get_command_windows('AZMON_ADX_DATABASE_NAME', @adxDatabaseName) + file.write(commands) # Close file after writing all environment variables file.close From c7511390b2d0d57e0ef329101ec71cf8fac4e478 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Mon, 4 Oct 2021 15:27:10 -0700 Subject: [PATCH 10/13] Tweaked and tested --- build/common/installer/scripts/tomlparser.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build/common/installer/scripts/tomlparser.rb b/build/common/installer/scripts/tomlparser.rb index abc704e84..32ea09aa3 100644 --- a/build/common/installer/scripts/tomlparser.rb +++ b/build/common/installer/scripts/tomlparser.rb @@ -178,18 +178,21 @@ def populateSettingValuesFromConfigMap(parsedConfig) #Get ADX database name setting begin - if !parsedConfig[:log_collection_settings][:adx_database_name].nil? - if !parsedConfig[:log_collection_settings][:adx_database_name].empty? - @adxDatabaseName = parsedConfig[:log_collection_settings][:adx_database_name] + if !parsedConfig[:log_collection_settings][:adx_database].nil? && !parsedConfig[:log_collection_settings][:adx_database][:name].nil? + if !parsedConfig[:log_collection_settings][:adx_database][:name].empty? + @adxDatabaseName = parsedConfig[:log_collection_settings][:adx_database][:name] puts "config::Using config map setting for ADX database name : #{@adxDatabaseName}" else - puts "config::Ignoring config map settings and using default value since provided adx database name value is empty" - end + puts "config::Ignoring config map settings and using default value '#{@adxDatabaseName}' since provided adx database name value is empty" + end + else + puts "config::No ADX database name set, using default value : #{@adxDatabaseName}" end rescue => errorStr ConfigParseErrorLogger.logError("Exception while reading config map settings for adx database name - #{errorStr}, using default #{@adxDatabaseName}, please check config map for errors") end + end end end From 2761cda5122dba85c20594331cb3d61b3f088ccc Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Mon, 4 Oct 2021 15:32:00 -0700 Subject: [PATCH 11/13] Code review --- source/plugins/go/src/oms.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index 6688125e5..8eeaaffa7 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -1741,7 +1741,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { } // AdxDatabaseName should never get in a state where its length is 0, but it doesn't hurt to add the check - if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 && len(AdxDatabaseName) == 0 { + if len(AdxClusterUri) > 0 && len(AdxClientID) > 0 && len(AdxClientSecret) > 0 && len(AdxTenantID) > 0 && len(AdxDatabaseName) > 0 { ContainerLogsRouteADX = true Log("Routing container logs thru %s route...", ContainerLogsADXRoute) fmt.Fprintf(os.Stdout, "Routing container logs thru %s route...\n", ContainerLogsADXRoute) From d823971afb958205e0e309d27280ee5bacbefe45 Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Tue, 26 Oct 2021 13:21:58 -0700 Subject: [PATCH 12/13] Review follow-up --- source/plugins/go/src/oms.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index 8eeaaffa7..f201646f4 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -1701,19 +1701,19 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { ContainerLogsRouteV2 = false ContainerLogsRouteADX = false - - // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. This SHOULD be set by tomlparser.rb so - // it's a highly unexpected event if it isn't. - // It should be set by the logic in tomlparser.rb EVEN if ADX logging isn't enabled - AdxDatabaseName := strings.TrimSpace(os.Getenv("AZMON_ADX_DATABASE_NAME")) - - // Check the len of the provided name for database and use default if 0, just to be sure - if len(AdxDatabaseName) == 0 { - Log("Adx database name unexpecedly empty (check config AND implementation, should have been set by tomlparser.rb?) - will default to '%s'", DefaultAdxDatabaseName) - AdxDatabaseName = DefaultAdxDatabaseName - } if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { + // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. + // This SHOULD be set by tomlparser.rb so it's a highly unexpected event if it isn't. + // It should be set by the logic in tomlparser.rb EVEN if ADX logging isn't enabled + AdxDatabaseName := strings.TrimSpace(os.Getenv("AZMON_ADX_DATABASE_NAME")) + + // Check the len of the provided name for database and use default if 0, just to be sure + if len(AdxDatabaseName) == 0 { + Log("Adx database name unexpecedly empty (check config AND implementation, should have been set by tomlparser.rb?) - will default to '%s'", DefaultAdxDatabaseName) + AdxDatabaseName = DefaultAdxDatabaseName + } + //check if adx clusteruri, clientid & secret are set var err error AdxClusterUri, err = ReadFileContents(PluginConfiguration["adx_cluster_uri_path"]) From 189d0a5b80cee79eb409a25b8b0420101a3abf4d Mon Sep 17 00:00:00 2001 From: Anders Johansen Date: Tue, 26 Oct 2021 13:27:18 -0700 Subject: [PATCH 13/13] Remove whitespace --- source/plugins/go/src/oms.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/plugins/go/src/oms.go b/source/plugins/go/src/oms.go index f201646f4..ee221a60b 100644 --- a/source/plugins/go/src/oms.go +++ b/source/plugins/go/src/oms.go @@ -1701,7 +1701,7 @@ func InitializePlugin(pluginConfPath string, agentVersion string) { ContainerLogsRouteV2 = false ContainerLogsRouteADX = false - + if strings.Compare(ContainerLogsRoute, ContainerLogsADXRoute) == 0 { // Try to read the ADX database name from environment variables. Default to DefaultAdsDatabaseName if not set. // This SHOULD be set by tomlparser.rb so it's a highly unexpected event if it isn't.