Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ac3fe16
trim log tag for cri compatible log lines
ganga1980 Feb 9, 2020
2f7673d
fix variable declaration
ganga1980 Feb 9, 2020
8756d77
debug log messages
ganga1980 Feb 11, 2020
3c1a347
trim spaces
ganga1980 Feb 11, 2020
eb89239
remove debug logs
ganga1980 Feb 11, 2020
54a99f2
fix build error
ganga1980 Feb 11, 2020
c2f6609
add pods api in cadvisor
ganga1980 Feb 12, 2020
1eb2e0a
wip
ganga1980 Feb 13, 2020
d647a41
wip
ganga1980 Feb 13, 2020
9356843
wip
ganga1980 Feb 13, 2020
6cf3e50
wip
ganga1980 Feb 13, 2020
358513f
fix bug
ganga1980 Feb 13, 2020
8f41eb2
fix bug
ganga1980 Feb 13, 2020
889a37d
fix bug with end
ganga1980 Feb 13, 2020
fbeb65c
fix bug in the reference
ganga1980 Feb 14, 2020
6ca9881
fix bug
ganga1980 Feb 14, 2020
3798163
fix telemetry
ganga1980 Feb 14, 2020
df95276
fix image and imageid bug
ganga1980 Feb 14, 2020
fff4351
fix containerid bug
ganga1980 Feb 15, 2020
40a915d
fix envvars
ganga1980 Feb 16, 2020
cdaa9e8
fix syntax error
ganga1980 Feb 16, 2020
f17dd91
fix syntax error
ganga1980 Feb 16, 2020
50404aa
fix env and command
ganga1980 Feb 16, 2020
8bf65cc
handle labels and annotation fieldref as envs
ganga1980 Feb 18, 2020
809bf77
wip
ganga1980 Feb 19, 2020
99fa994
implement obtain envvars
ganga1980 Feb 20, 2020
6f70046
refactor the code
ganga1980 Feb 20, 2020
a704ac4
fix log warn
ganga1980 Feb 20, 2020
e0905d3
add more logging
ganga1980 Feb 20, 2020
264aa31
fix npe
ganga1980 Feb 20, 2020
c218c19
revert kubelet api to get the envvars
ganga1980 Feb 21, 2020
977b0fe
fix minor issue
ganga1980 Feb 21, 2020
e785c4a
fix log message
ganga1980 Feb 21, 2020
f0a5f2c
comment valueFrom for now since this causing some issue
ganga1980 Feb 21, 2020
7d40af1
fix formatting issue
ganga1980 Feb 22, 2020
13bc75d
fix bug
ganga1980 Feb 22, 2020
d5ff077
add resourcefieldref support in env
ganga1980 Feb 23, 2020
fca1ce5
include init containers as well
ganga1980 Feb 23, 2020
765d352
fix bug
ganga1980 Feb 23, 2020
73b694a
fix typo
ganga1980 Feb 24, 2020
7f00a87
use chomp instead of delete_suffix
ganga1980 Feb 24, 2020
c95a457
add secretkeyref support
ganga1980 Feb 24, 2020
03796ae
add secretkeyref support
ganga1980 Feb 24, 2020
aa912b0
fix bug
ganga1980 Feb 24, 2020
213adac
handle dockerversion for non-docker runtimes
ganga1980 Feb 25, 2020
bf43eda
Merge branch 'ci_feature' into gangams/add-support-cri-runtime
ganga1980 Feb 26, 2020
94b589f
fix comment
ganga1980 Feb 26, 2020
3b45208
Merge branch 'ci_feature' into gangams/add-support-cri-runtime
ganga1980 Feb 27, 2020
10aac9e
handle kubelet metrics to handle runtime and k8s versions
ganga1980 Mar 3, 2020
8a114d1
remove _total metrics until we support 1.18
ganga1980 Mar 4, 2020
06a51cf
fetch envvars via proc environ
ganga1980 Mar 6, 2020
a06d5c3
fix undefined vars
ganga1980 Mar 6, 2020
b2ea71a
fix undefined vars
ganga1980 Mar 6, 2020
6d145a6
add init containers
ganga1980 Mar 8, 2020
fcb47e5
split on null character
ganga1980 Mar 8, 2020
69c945c
consider crio containers main proceses for envvars
ganga1980 Mar 8, 2020
44b7374
unschedule pods or containers with pull issues
ganga1980 Mar 8, 2020
195a919
fix issue
ganga1980 Mar 8, 2020
ed364dd
fix feedback
ganga1980 Mar 10, 2020
3a5d0ec
update to azmon parsers
ganga1980 Mar 11, 2020
7ad5800
fix file extension
ganga1980 Mar 11, 2020
0c9ca6d
add some debug messages
ganga1980 Mar 11, 2020
fcdd967
fix timestamp issue
ganga1980 Mar 11, 2020
afec656
fix pr feedback
ganga1980 Mar 12, 2020
7cdbb52
refactor linux containerenvvars code
ganga1980 Mar 13, 2020
2c27992
refactor windows container inventory code
ganga1980 Mar 13, 2020
4239966
fix rb file load error from in_kube_node inventory
ganga1980 Mar 13, 2020
d8b339f
add new rb file base_container.data
ganga1980 Mar 13, 2020
46ce174
turnoff docker container inventory
ganga1980 Mar 16, 2020
1e9da62
cleanup debug logs
ganga1980 Mar 16, 2020
e24e84f
fix npe in log message
ganga1980 Mar 17, 2020
545a6ff
avoid environ for terminated containers
ganga1980 Mar 18, 2020
55fcc4b
Merge branch 'ci_feature' into gangams/add-support-cri-runtime-docker…
ganga1980 Mar 19, 2020
393f843
fix pr feedback
ganga1980 Mar 19, 2020
b846532
remove empty file
ganga1980 Mar 19, 2020
77f6ae3
clean up debug logs
ganga1980 Mar 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions installer/conf/azm-containers-parser.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[PARSER]
Name docker
Format json
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
Time_Keep On
# Command | Decoder | Field | Optional Action
# =============|==================|=================
Decode_Field_As escaped log

[PARSER]
# http://rubular.com/r/tjUt3Awgg4
Name cri
Format regex
Regex ^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[^ ]*) (?<log>.*)$
Time_Key time
Time_Format %Y-%m-%dT%H:%M:%S.%L
Time_Keep On

2 changes: 1 addition & 1 deletion installer/conf/td-agent-bit-rs.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[SERVICE]
Flush 30
Log_Level info
Parsers_File /etc/td-agent-bit/parsers.conf
Parsers_File /etc/opt/microsoft/docker-cimprov/azm-containers-parser.conf
Log_File /var/opt/microsoft/docker-cimprov/log/fluent-bit.log

[INPUT]
Expand Down
2 changes: 1 addition & 1 deletion installer/conf/td-agent-bit.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#Default service flush interval is 15 seconds
${SERVICE_FLUSH_INTERVAL}
Log_Level info
Parsers_File /etc/td-agent-bit/parsers.conf
Parsers_File /etc/opt/microsoft/docker-cimprov/azm-containers-parser.conf
Log_File /var/opt/microsoft/docker-cimprov/log/fluent-bit.log

[INPUT]
Expand Down
9 changes: 5 additions & 4 deletions installer/conf/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
# report_active = true
# fieldpass = ["usage_active","cluster","node","host","device"]
# taginclude = ["cluster","cpu","node"]



# Read metrics about disk usage by mount point
Expand All @@ -395,7 +395,7 @@
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
# mount_points = ["/"]

## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]
fieldpass = ["free", "used", "used_percent"]
Expand Down Expand Up @@ -532,7 +532,8 @@
name_prefix="container.azm.ms/"
## An array of urls to scrape metrics from.
urls = ["$CADVISOR_METRICS_URL"]
fieldpass = ["kubelet_docker_operations", "kubelet_docker_operations_errors"]
## Include "$KUBELET_RUNTIME_OPERATIONS_TOTAL_METRIC", "$KUBELET_RUNTIME_OPERATIONS_ERRORS_TOTAL_METRIC" when we add for support for 1.18
fieldpass = ["$KUBELET_RUNTIME_OPERATIONS_METRIC", "$KUBELET_RUNTIME_OPERATIONS_ERRORS_METRIC"]

metric_version = 2
url_tag = "scrapeUrl"
Expand Down Expand Up @@ -578,7 +579,7 @@
urls = $AZMON_DS_PROM_URLS

fieldpass = $AZMON_DS_PROM_FIELDPASS

fielddrop = $AZMON_DS_PROM_FIELDDROP

metric_version = 2
Expand Down
3 changes: 3 additions & 0 deletions installer/datafiles/base_container.data
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ MAINTAINER: 'Microsoft Corporation'
/opt/microsoft/omsagent/plugin/DockerApiClient.rb; source/code/plugin/DockerApiClient.rb; 644; root; root
/opt/microsoft/omsagent/plugin/DockerApiRestHelper.rb; source/code/plugin/DockerApiRestHelper.rb; 644; root; root
/opt/microsoft/omsagent/plugin/in_containerinventory.rb; source/code/plugin/in_containerinventory.rb; 644; root; root
/opt/microsoft/omsagent/plugin/kubernetes_container_inventory.rb; source/code/plugin/kubernetes_container_inventory.rb; 644; root; root


/opt/microsoft/omsagent/plugin/out_mdm.rb; source/code/plugin/out_mdm.rb; 644; root; root
/opt/microsoft/omsagent/plugin/filter_cadvisor2mdm.rb; source/code/plugin/filter_cadvisor2mdm.rb; 644; root; root
Expand Down Expand Up @@ -106,6 +108,7 @@ MAINTAINER: 'Microsoft Corporation'
/opt/td-agent-bit/bin/out_oms.so; intermediate/${{BUILD_CONFIGURATION}}/out_oms.so; 755; root; root
/etc/opt/microsoft/docker-cimprov/td-agent-bit.conf; installer/conf/td-agent-bit.conf; 644; root; root
/etc/opt/microsoft/docker-cimprov/td-agent-bit-rs.conf; installer/conf/td-agent-bit-rs.conf; 644; root; root
/etc/opt/microsoft/docker-cimprov/azm-containers-parser.conf; installer/conf/azm-containers-parser.conf; 644; root; root
/etc/opt/microsoft/docker-cimprov/out_oms.conf; installer/conf/out_oms.conf; 644; root; root
/etc/opt/microsoft/docker-cimprov/telegraf.conf; installer/conf/telegraf.conf; 644; root; root
/etc/opt/microsoft/docker-cimprov/telegraf-rs.conf; installer/conf/telegraf-rs.conf; 644; root; root
Expand Down
20 changes: 16 additions & 4 deletions source/code/go/src/plugins/oms.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const ResourceIdEnv = "AKS_RESOURCE_ID"
//env variable which has ResourceName for NON-AKS
const ResourceNameEnv = "ACS_RESOURCE_NAME"

//env variable which has container run time name
const ContainerRuntimeEnv = "CONTAINER_RUNTIME"

// Origin prefix for telegraf Metrics (used as prefix for origin field & prefix for azure monitor specific tags and also for custom-metrics telemetry )
const TelegrafMetricOriginPrefix = "container.azm.ms"

Expand Down Expand Up @@ -94,7 +97,9 @@ var (
//KubeMonAgentEvents skip first flush
skipKubeMonEventsFlush bool
// enrich container logs (when true this will add the fields - timeofcommand, containername & containerimage)
enrichContainerLogs bool
enrichContainerLogs bool
// container runtime engine configured on the kubelet
containerRuntime string
)

var (
Expand Down Expand Up @@ -750,9 +755,11 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int {

stringMap := make(map[string]string)

stringMap["LogEntry"] = ToString(record["log"])
logEntry := ToString(record["log"])
logEntryTimeStamp := ToString(record["time"])
stringMap["LogEntry"] = logEntry
stringMap["LogEntrySource"] = logEntrySource
stringMap["LogEntryTimeStamp"] = ToString(record["time"])
stringMap["LogEntryTimeStamp"] = logEntryTimeStamp
stringMap["SourceSystem"] = "Containers"
stringMap["Id"] = containerID

Expand Down Expand Up @@ -797,7 +804,7 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int {
if dataItem.LogEntryTimeStamp != "" {
loggedTime, e := time.Parse(time.RFC3339, dataItem.LogEntryTimeStamp)
if e != nil {
message := fmt.Sprintf("Error while converting LogEntryTimeStamp for telemetry purposes: %s", e.Error())
message := fmt.Sprintf("containerId: %s Error while converting LogEntryTimeStamp for telemetry purposes: %s", dataItem.ID, e.Error())
Log(message)
SendException(message)
} else {
Expand Down Expand Up @@ -977,6 +984,11 @@ func InitializePlugin(pluginConfPath string, agentVersion string) {
Log("ResourceID=%s", ResourceID)
Log("ResourceName=%s", ResourceName)
}

// log runtime info for debug purpose
containerRuntime = os.Getenv(ContainerRuntimeEnv)
Log("Container Runtime engine %s", containerRuntime)


//set useragent to be used by ingestion
docker_cimprov_version := strings.TrimSpace(os.Getenv("DOCKER_CIMPROV_VERSION"))
Expand Down
27 changes: 17 additions & 10 deletions source/code/plugin/ApplicationInsightsUtility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ApplicationInsightsUtility
require_relative "omslog"
require_relative "DockerApiClient"
require_relative "oms_common"
require 'yajl/json_gem'
require "yajl/json_gem"
require "base64"

@@HeartBeat = "HeartBeatEvent"
Expand All @@ -20,6 +20,7 @@ class ApplicationInsightsUtility
@@EnvApplicationInsightsKey = "APPLICATIONINSIGHTS_AUTH"
@@EnvApplicationInsightsEndpoint = "APPLICATIONINSIGHTS_ENDPOINT"
@@EnvControllerType = "CONTROLLER_TYPE"
@@EnvContainerRuntime = "CONTAINER_RUNTIME"

@@CustomProperties = {}
@@Tc = nil
Expand Down Expand Up @@ -73,7 +74,7 @@ def initializeUtility()
@@Tc = ApplicationInsights::TelemetryClient.new
elsif !encodedAppInsightsKey.nil?
decodedAppInsightsKey = Base64.decode64(encodedAppInsightsKey)

#override ai endpoint if its available otherwise use default.
if appInsightsEndpoint && !appInsightsEndpoint.nil? && !appInsightsEndpoint.empty?
$log.info("AppInsightsUtility: Telemetry client uses overrided endpoint url : #{appInsightsEndpoint}")
Expand Down Expand Up @@ -110,11 +111,17 @@ def initializeUtility()
end
end

def getDockerInfo()
dockerInfo = DockerApiClient.dockerInfo
if (!dockerInfo.nil? && !dockerInfo.empty?)
@@CustomProperties["DockerVersion"] = dockerInfo["Version"]
#@@CustomProperties["DockerApiVersion"] = dockerInfo["ApiVersion"]
def getContainerRuntimeInfo()
containerRuntime = ENV[@@EnvContainerRuntime]
if !containerRuntime.nil? && !containerRuntime.empty?
# DockerVersion field holds either containerRuntime for non-docker or Dockerversion if its docker
@@CustomProperties["DockerVersion"] = containerRuntime
if containerRuntime.casecmp("docker") == 0
dockerInfo = DockerApiClient.dockerInfo
if (!dockerInfo.nil? && !dockerInfo.empty?)
@@CustomProperties["DockerVersion"] = dockerInfo["Version"]
end
end
end
end

Expand Down Expand Up @@ -169,7 +176,7 @@ def sendExceptionTelemetry(errorStr, properties = nil)
if @@CustomProperties.empty? || @@CustomProperties.nil?
initializeUtility()
elsif @@CustomProperties["DockerVersion"].nil?
getDockerInfo()
getContainerRuntimeInfo()
end
telemetryProps = {}
# add common dimensions
Expand All @@ -193,7 +200,7 @@ def sendTelemetry(pluginName, properties)
if @@CustomProperties.empty? || @@CustomProperties.nil?
initializeUtility()
elsif @@CustomProperties["DockerVersion"].nil?
getDockerInfo()
getContainerRuntimeInfo()
end
@@CustomProperties["Computer"] = properties["Computer"]
sendHeartBeatEvent(pluginName)
Expand All @@ -213,7 +220,7 @@ def sendMetricTelemetry(metricName, metricValue, properties)
if @@CustomProperties.empty? || @@CustomProperties.nil?
initializeUtility()
elsif @@CustomProperties["DockerVersion"].nil?
getDockerInfo()
getContainerRuntimeInfo()
end
telemetryProps = {}
# add common dimensions
Expand Down
5 changes: 5 additions & 0 deletions source/code/plugin/CAdvisorMetricsAPIClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ def getNodeCapacityFromCAdvisor(winNode: nil)
return getResponse(winNode, relativeUri)
end

def getPodsFromCAdvisor(winNode: nil)
relativeUri = "/pods"
return getResponse(winNode, relativeUri)
end

def getBaseCAdvisorUri(winNode)
cAdvisorSecurePort = isCAdvisorOnSecurePort()

Expand Down
Loading