From 1f7a5d7a8abe806969c0a72a3558d95b5463eedc Mon Sep 17 00:00:00 2001 From: Keiko Harada Date: Fri, 8 Mar 2019 13:57:40 -0800 Subject: [PATCH] Keiko alertdoc (#238) * fix kubernetes yaml and doc (#93) * 1.4.4-210 agent updated (#94) * agent -42 release updates (#108) * Fix break for openshift (#111) * updating yaml to reflect latest released versions (#112) * Add mount path to /var/lib/docker/containers (#114) * Update README.md (#126) adding --mount type=bind,source=/var/lib/docker/containers,destination=/var/lib/docker/containers as per IcM 75500254 * Update ws-omsagent-de-secrets.yaml (#102) Replaced tab with spaces * Add container log mount path in yaml (#127) * Add container log mount path * Add container log mount path * Update ocp-omsagent.yaml * Update ocp-ds-omsagent.yaml * v 1.6.0-163 (#133) * v 1.6.0-163 * updating label * updating versions (#136) * Updating to 1.0.0-35 docker provider build (#148) * Updating to 1.0.0-35 docker provider build * Updating docker provider to latest version 1.0.0-35 * updating oms agent to use the latest version 1.8.1-256 (#227) * updating oms agent to latest * updating yaml * alert doc * alert doc1 * modified: NotReadyQuery.md modified: NotReadyQuery.md * modified: NotReadyQuery.md modified: NotReadyQuery.md modified: README.md --- 1.4.4-210/Dockerfile | 11 +++ 1.4.4-210/main.sh | 80 ++++++++++++++++ 1.4.4-210/setup.sh | 17 ++++ 1.6.0-163/Dockerfile | 11 +++ 1.6.0-163/main.sh | 93 +++++++++++++++++++ 1.6.0-163/setup.sh | 40 ++++++++ 1.6.0-42/Dockerfile | 11 +++ 1.6.0-42/main.sh | 93 +++++++++++++++++++ 1.6.0-42/setup.sh | 32 +++++++ 1.8.1-256/Dockerfile | 11 +++ 1.8.1-256/main.sh | 93 +++++++++++++++++++ 1.8.1-256/setup.sh | 32 +++++++ Alerting/NotReadyQuery.md | 24 +++++ Alerting/PendingPodCount.md | 33 +++++++ Alerting/README.md | 26 ++++++ Kubernetes/README.md | 3 +- Kubernetes/omsagent-ds-secrets.yaml | 2 +- .../windows/ws-omsagent-de-secrets.yaml | 2 +- OpenShift/ocp-ds-omsagent.yaml | 5 + OpenShift/ocp-omsagent.yaml | 5 + README.md | 4 +- Swarmmode/README.md | 2 +- 22 files changed, 624 insertions(+), 6 deletions(-) create mode 100644 1.4.4-210/Dockerfile create mode 100644 1.4.4-210/main.sh create mode 100644 1.4.4-210/setup.sh create mode 100644 1.6.0-163/Dockerfile create mode 100644 1.6.0-163/main.sh create mode 100644 1.6.0-163/setup.sh create mode 100644 1.6.0-42/Dockerfile create mode 100644 1.6.0-42/main.sh create mode 100644 1.6.0-42/setup.sh create mode 100644 1.8.1-256/Dockerfile create mode 100644 1.8.1-256/main.sh create mode 100644 1.8.1-256/setup.sh create mode 100644 Alerting/NotReadyQuery.md create mode 100644 Alerting/PendingPodCount.md create mode 100644 Alerting/README.md diff --git a/1.4.4-210/Dockerfile b/1.4.4-210/Dockerfile new file mode 100644 index 00000000..cb483d36 --- /dev/null +++ b/1.4.4-210/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 +MAINTAINER OMSContainers@microsoft.com +LABEL vendor=Microsoft\ Corp \ +com.microsoft.product="OMS Container Docker Provider" \ +com.microsoft.version="1.0.0-31" +ENV tmpdir /opt +RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes sysv-rc net-tools rsyslog cron vim dmidecode apt-transport-https && rm -rf /var/lib/apt/lists/* +COPY setup.sh main.sh $tmpdir/ +WORKDIR ${tmpdir} +RUN chmod 775 $tmpdir/*.sh; sync; $tmpdir/setup.sh +CMD [ "/opt/main.sh" ] diff --git a/1.4.4-210/main.sh b/1.4.4-210/main.sh new file mode 100644 index 00000000..cb5ff0be --- /dev/null +++ b/1.4.4-210/main.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/syslog.conf +sed -i -e 's/^exit 101$/exit 0/g' /usr/sbin/policy-rc.d + +#Using the get_hostname for hostname instead of the host field in syslog messages +sed -i.bak "s/record\[\"Host\"\] = hostname/record\[\"Host\"\] = OMS::Common.get_hostname/" /opt/microsoft/omsagent/plugin/filter_syslog.rb + +#using /var/opt/microsoft/docker-cimprov/state instead of /var/opt/microsoft/omsagent/state since the latter gets deleted during onboarding +mkdir -p /var/opt/microsoft/docker-cimprov/state +if [[ "$KUBERNETES_SERVICE_HOST" ]];then + #kubernetes treats node names as lower case + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name'].lower()" > /var/opt/microsoft/docker-cimprov/state/containerhostname +else + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name']" > /var/opt/microsoft/docker-cimprov/state/containerhostname +fi +#check if file was written successfully +cat /var/opt/microsoft/docker-cimprov/state/containerhostname + +#Setup sudo permission for containerlogtailfilereader +chmod +w /etc/sudoers.d/omsagent +echo "#run containerlogtailfilereader.rb for docker-provider" >> /etc/sudoers.d/omsagent +echo "omsagent ALL=(ALL) NOPASSWD: /opt/microsoft/omsagent/ruby/bin/ruby /opt/microsoft/omsagent/plugin/containerlogtailfilereader.rb *" >> /etc/sudoers.d/omsagent +chmod 440 /etc/sudoers.d/omsagent + +#Disable dsc & copy container tailfilereader +/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable +rm -f /etc/opt/microsoft/omsagent/conf/omsagent.d/omsconfig.consistencyinvoker.conf +#cp -f /opt/microsoft/docker-cimprov/tailfilereader.rb /opt/microsoft/omsagent/plugin/. + +#service omid start +/opt/omi/bin/omiserver -s +/opt/omi/bin/omiserver --configfile=/etc/opt/omi/conf/omiserver.conf -d + +if [ -z $INT ]; then + if [ -a /etc/omsagent-secret/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` -d `cat /etc/omsagent-secret/DOMAIN` + elif [ -a /etc/omsagent-secret/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` + elif [ -a /run/secrets/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` -d `cat /run/secrets/DOMAIN` + elif [ -a /run/secrets/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` + elif [ -z $DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY + else + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY -d $DOMAIN + fi +else + echo WORKSPACE_ID=$WSID > /etc/omsagent-onboard.conf + echo SHARED_KEY=$KEY >> /etc/omsagent-onboard.conf + /opt/microsoft/omsagent/bin/omsadmin.sh +fi + +#Hack for omi upgrade + + /opt/omi/bin/omicli id + /opt/omi/bin/omicli ei root/cimv2 Container_HostInventory + +#service omsagent start +#/opt/microsoft/omsagent/bin/service_control start + +#check if agent onboarded successfully +/opt/microsoft/omsagent/bin/omsadmin.sh -l + +#get omsagent and docker-provider versions +dpkg -l | grep omi | awk '{print $2 " " $3}' +dpkg -l | grep omsagent | awk '{print $2 " " $3}' +dpkg -l | grep docker-cimprov | awk '{print $2 " " $3}' + + +shutdown() { + /opt/omi/bin/service_control stop + /opt/microsoft/omsagent/bin/service_control stop + } + +trap "shutdown" SIGTERM + +sleep inf & wait diff --git a/1.4.4-210/setup.sh b/1.4.4-210/setup.sh new file mode 100644 index 00000000..3e21b283 --- /dev/null +++ b/1.4.4-210/setup.sh @@ -0,0 +1,17 @@ +TMPDIR="/opt" +cd $TMPDIR +wget https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_GA_v1.4.4-210/omsagent-1.4.4-210.universal.x64.sh +wget https://github.com/Microsoft/Docker-Provider/releases/download/1.0.0-31/docker-cimprov-1.0.0-31.universal.x86_64.sh +chmod 775 $TMPDIR/*.sh + +$TMPDIR/omsagent-*.universal.x64.sh --extract +mv $TMPDIR/omsbundle* $TMPDIR/omsbundle +$TMPDIR/omsbundle/bundles/scx-1.6.*-*.universal.x64.sh --install +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsagent*.deb +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsconfig*.deb +#/$TMPDIR/omsbundle/oss-kits/docker-cimprov-1.0.0-*.x86_64.sh --install +#Use downloaded docker-provider instead of the bundled one +/$TMPDIR/docker-cimprov-1.0.0-*.x86_64.sh --install +rm -rf $TMPDIR/omsbundle +rm -f $TMPDIR/omsagent*.sh +rm -f $TMPDIR/docker-cimprov*.sh diff --git a/1.6.0-163/Dockerfile b/1.6.0-163/Dockerfile new file mode 100644 index 00000000..68e75e53 --- /dev/null +++ b/1.6.0-163/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 +MAINTAINER OMSContainers@microsoft.com +LABEL vendor=Microsoft\ Corp \ +com.microsoft.product="OMS Container Docker Provider" \ +com.microsoft.version="1.0.0-34" +ENV tmpdir /opt +RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes sysv-rc net-tools rsyslog cron vim dmidecode apt-transport-https && rm -rf /var/lib/apt/lists/* +COPY setup.sh main.sh $tmpdir/ +WORKDIR ${tmpdir} +RUN chmod 775 $tmpdir/*.sh; sync; $tmpdir/setup.sh +CMD [ "/opt/main.sh" ] diff --git a/1.6.0-163/main.sh b/1.6.0-163/main.sh new file mode 100644 index 00000000..ee7d0148 --- /dev/null +++ b/1.6.0-163/main.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/syslog.conf +sed -i -e 's/^exit 101$/exit 0/g' /usr/sbin/policy-rc.d + +#Using the get_hostname for hostname instead of the host field in syslog messages +sed -i.bak "s/record\[\"Host\"\] = hostname/record\[\"Host\"\] = OMS::Common.get_hostname/" /opt/microsoft/omsagent/plugin/filter_syslog.rb + +#using /var/opt/microsoft/docker-cimprov/state instead of /var/opt/microsoft/omsagent/state since the latter gets deleted during onboarding +mkdir -p /var/opt/microsoft/docker-cimprov/state +if [[ "$KUBERNETES_SERVICE_HOST" ]];then + #kubernetes treats node names as lower case + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name'].lower()" > /var/opt/microsoft/docker-cimprov/state/containerhostname + #dump kubernetes version to a file for telemetry purpose + curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://$KUBERNETES_SERVICE_HOST/api/v1/nodes | python -c "import sys, json; data=json.load(sys.stdin); kubeletversion = data['items'][0]['status']['nodeInfo']['kubeletVersion']; print kubeletversion;" > /var/opt/microsoft/docker-cimprov/state/kubeletversion + cat /var/opt/microsoft/docker-cimprov/state/kubeletversion +else + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name']" > /var/opt/microsoft/docker-cimprov/state/containerhostname +fi +#check if file was written successfully +cat /var/opt/microsoft/docker-cimprov/state/containerhostname + +#dump OMS agent Image tag for telemetry purpose +#step-1 dump the oms agent container imageID + curl --unix-socket /var/run/docker.sock "http:/containers/json" | python -c "import sys, json; data=json.load(sys.stdin); omscontainer=[item for item in data if item['Image'].startswith('microsoft/oms@sha256:')]; print omscontainer[0]['ImageID'];" > /var/opt/microsoft/docker-cimprov/state/omscontainerimageid + cat /var/opt/microsoft/docker-cimprov/state/omscontainerimageid +#step-2 dump the oms agent repo tags from imageID to be picked up by telemetry + if [ -e "/var/opt/microsoft/docker-cimprov/state/omscontainerimageid" ]; then + curl --unix-socket /var/run/docker.sock "http:/images/json" | python -c "import sys, json; data=json.load(sys.stdin); imageID = open('/var/opt/microsoft/docker-cimprov/state/omscontainerimageid', 'r').read().encode('ascii','ignore'); omscontainer=[item for item in data if imageID.rstrip('\n') in item['Id']]; print omscontainer[0]['RepoTags'];" > /var/opt/microsoft/docker-cimprov/state/omscontainertag + cat /var/opt/microsoft/docker-cimprov/state/omscontainertag + fi + +#Commenting it for test. We do this in the installer now. +#Setup sudo permission for containerlogtailfilereader +#chmod +w /etc/sudoers.d/omsagent +#echo "#run containerlogtailfilereader.rb for docker-provider" >> /etc/sudoers.d/omsagent +#echo "omsagent ALL=(ALL) NOPASSWD: /opt/microsoft/omsagent/ruby/bin/ruby /opt/microsoft/omsagent/plugin/containerlogtailfilereader.rb *" >> /etc/sudoers.d/omsagent +#chmod 440 /etc/sudoers.d/omsagent + +#Disable dsc +/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable +rm -f /etc/opt/microsoft/omsagent/conf/omsagent.d/omsconfig.consistencyinvoker.conf + +#service omid start +/opt/omi/bin/omiserver -s +/opt/omi/bin/omiserver --configfile=/etc/opt/omi/conf/omiserver.conf -d + +if [ -z $INT ]; then + if [ -a /etc/omsagent-secret/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` -d `cat /etc/omsagent-secret/DOMAIN` + elif [ -a /etc/omsagent-secret/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` + elif [ -a /run/secrets/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` -d `cat /run/secrets/DOMAIN` + elif [ -a /run/secrets/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` + elif [ -z $DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY + else + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY -d $DOMAIN + fi +else + echo WORKSPACE_ID=$WSID > /etc/omsagent-onboard.conf + echo SHARED_KEY=$KEY >> /etc/omsagent-onboard.conf + /opt/microsoft/omsagent/bin/omsadmin.sh +fi + +#Hack for omi upgrade + + /opt/omi/bin/omicli id + /opt/omi/bin/omicli ei root/cimv2 Container_HostInventory + +#start cron daemon for logrotate +service cron start + +#check if agent onboarded successfully +/opt/microsoft/omsagent/bin/omsadmin.sh -l + +#get omsagent and docker-provider versions +dpkg -l | grep omi | awk '{print $2 " " $3}' +dpkg -l | grep omsagent | awk '{print $2 " " $3}' +dpkg -l | grep docker-cimprov | awk '{print $2 " " $3}' + + +shutdown() { + /opt/omi/bin/service_control stop + /opt/microsoft/omsagent/bin/service_control stop + } + +trap "shutdown" SIGTERM + +sleep inf & wait diff --git a/1.6.0-163/setup.sh b/1.6.0-163/setup.sh new file mode 100644 index 00000000..176ce5bf --- /dev/null +++ b/1.6.0-163/setup.sh @@ -0,0 +1,40 @@ +TMPDIR="/opt" +cd $TMPDIR + +#Download utf-8 encoding capability on the omsagent container. + +apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales + +sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ + dpkg-reconfigure --frontend=noninteractive locales && \ + update-locale LANG=en_US.UTF-8 + +wget https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_v1.6.0-163/omsagent-1.6.0-163.universal.x64.sh + +#create file to disable omi service startup script +touch /etc/.omi_disable_service_control +wget https://github.com/Microsoft/Docker-Provider/releases/download/1.0.0-35/docker-cimprov-1.0.0-35.universal.x86_64.sh +chmod 775 $TMPDIR/*.sh + +#Extract omsbundle +$TMPDIR/omsagent-*.universal.x64.sh --extract +mv $TMPDIR/omsbundle* $TMPDIR/omsbundle +#Install omi +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omi*.deb + +#Install scx +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/scx*.deb +#$TMPDIR/omsbundle/bundles/scx-1.6.*-*.universal.x64.sh --install + +#Install omsagent and omsconfig + +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsagent*.deb +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsconfig*.deb +#/$TMPDIR/omsbundle/oss-kits/docker-cimprov-1.0.0-*.x86_64.sh --install +#Use downloaded docker-provider instead of the bundled one + +/$TMPDIR/docker-cimprov-1.0.0-*.x86_64.sh --install + +rm -rf $TMPDIR/omsbundle +rm -f $TMPDIR/omsagent*.sh +rm -f $TMPDIR/docker-cimprov*.sh diff --git a/1.6.0-42/Dockerfile b/1.6.0-42/Dockerfile new file mode 100644 index 00000000..24bc5738 --- /dev/null +++ b/1.6.0-42/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 +MAINTAINER OMSContainers@microsoft.com +LABEL vendor=Microsoft\ Corp \ +com.microsoft.product="OMS Container Docker Provider" \ +com.microsoft.version="1.0.0-33" +ENV tmpdir /opt +RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes sysv-rc net-tools rsyslog cron vim dmidecode apt-transport-https && rm -rf /var/lib/apt/lists/* +COPY setup.sh main.sh $tmpdir/ +WORKDIR ${tmpdir} +RUN chmod 775 $tmpdir/*.sh; sync; $tmpdir/setup.sh +CMD [ "/opt/main.sh" ] diff --git a/1.6.0-42/main.sh b/1.6.0-42/main.sh new file mode 100644 index 00000000..ee7d0148 --- /dev/null +++ b/1.6.0-42/main.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/syslog.conf +sed -i -e 's/^exit 101$/exit 0/g' /usr/sbin/policy-rc.d + +#Using the get_hostname for hostname instead of the host field in syslog messages +sed -i.bak "s/record\[\"Host\"\] = hostname/record\[\"Host\"\] = OMS::Common.get_hostname/" /opt/microsoft/omsagent/plugin/filter_syslog.rb + +#using /var/opt/microsoft/docker-cimprov/state instead of /var/opt/microsoft/omsagent/state since the latter gets deleted during onboarding +mkdir -p /var/opt/microsoft/docker-cimprov/state +if [[ "$KUBERNETES_SERVICE_HOST" ]];then + #kubernetes treats node names as lower case + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name'].lower()" > /var/opt/microsoft/docker-cimprov/state/containerhostname + #dump kubernetes version to a file for telemetry purpose + curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://$KUBERNETES_SERVICE_HOST/api/v1/nodes | python -c "import sys, json; data=json.load(sys.stdin); kubeletversion = data['items'][0]['status']['nodeInfo']['kubeletVersion']; print kubeletversion;" > /var/opt/microsoft/docker-cimprov/state/kubeletversion + cat /var/opt/microsoft/docker-cimprov/state/kubeletversion +else + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name']" > /var/opt/microsoft/docker-cimprov/state/containerhostname +fi +#check if file was written successfully +cat /var/opt/microsoft/docker-cimprov/state/containerhostname + +#dump OMS agent Image tag for telemetry purpose +#step-1 dump the oms agent container imageID + curl --unix-socket /var/run/docker.sock "http:/containers/json" | python -c "import sys, json; data=json.load(sys.stdin); omscontainer=[item for item in data if item['Image'].startswith('microsoft/oms@sha256:')]; print omscontainer[0]['ImageID'];" > /var/opt/microsoft/docker-cimprov/state/omscontainerimageid + cat /var/opt/microsoft/docker-cimprov/state/omscontainerimageid +#step-2 dump the oms agent repo tags from imageID to be picked up by telemetry + if [ -e "/var/opt/microsoft/docker-cimprov/state/omscontainerimageid" ]; then + curl --unix-socket /var/run/docker.sock "http:/images/json" | python -c "import sys, json; data=json.load(sys.stdin); imageID = open('/var/opt/microsoft/docker-cimprov/state/omscontainerimageid', 'r').read().encode('ascii','ignore'); omscontainer=[item for item in data if imageID.rstrip('\n') in item['Id']]; print omscontainer[0]['RepoTags'];" > /var/opt/microsoft/docker-cimprov/state/omscontainertag + cat /var/opt/microsoft/docker-cimprov/state/omscontainertag + fi + +#Commenting it for test. We do this in the installer now. +#Setup sudo permission for containerlogtailfilereader +#chmod +w /etc/sudoers.d/omsagent +#echo "#run containerlogtailfilereader.rb for docker-provider" >> /etc/sudoers.d/omsagent +#echo "omsagent ALL=(ALL) NOPASSWD: /opt/microsoft/omsagent/ruby/bin/ruby /opt/microsoft/omsagent/plugin/containerlogtailfilereader.rb *" >> /etc/sudoers.d/omsagent +#chmod 440 /etc/sudoers.d/omsagent + +#Disable dsc +/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable +rm -f /etc/opt/microsoft/omsagent/conf/omsagent.d/omsconfig.consistencyinvoker.conf + +#service omid start +/opt/omi/bin/omiserver -s +/opt/omi/bin/omiserver --configfile=/etc/opt/omi/conf/omiserver.conf -d + +if [ -z $INT ]; then + if [ -a /etc/omsagent-secret/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` -d `cat /etc/omsagent-secret/DOMAIN` + elif [ -a /etc/omsagent-secret/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` + elif [ -a /run/secrets/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` -d `cat /run/secrets/DOMAIN` + elif [ -a /run/secrets/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` + elif [ -z $DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY + else + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY -d $DOMAIN + fi +else + echo WORKSPACE_ID=$WSID > /etc/omsagent-onboard.conf + echo SHARED_KEY=$KEY >> /etc/omsagent-onboard.conf + /opt/microsoft/omsagent/bin/omsadmin.sh +fi + +#Hack for omi upgrade + + /opt/omi/bin/omicli id + /opt/omi/bin/omicli ei root/cimv2 Container_HostInventory + +#start cron daemon for logrotate +service cron start + +#check if agent onboarded successfully +/opt/microsoft/omsagent/bin/omsadmin.sh -l + +#get omsagent and docker-provider versions +dpkg -l | grep omi | awk '{print $2 " " $3}' +dpkg -l | grep omsagent | awk '{print $2 " " $3}' +dpkg -l | grep docker-cimprov | awk '{print $2 " " $3}' + + +shutdown() { + /opt/omi/bin/service_control stop + /opt/microsoft/omsagent/bin/service_control stop + } + +trap "shutdown" SIGTERM + +sleep inf & wait diff --git a/1.6.0-42/setup.sh b/1.6.0-42/setup.sh new file mode 100644 index 00000000..b8e32526 --- /dev/null +++ b/1.6.0-42/setup.sh @@ -0,0 +1,32 @@ +TMPDIR="/opt" +cd $TMPDIR + +wget https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_v1.6.0-42/omsagent-1.6.0-42.universal.x64.sh + +#create file to disable omi service startup script +touch /etc/.omi_disable_service_control +wget https://github.com/Microsoft/Docker-Provider/releases/download/1.0.0-33/docker-cimprov-1.0.0-33.universal.x86_64.sh +chmod 775 $TMPDIR/*.sh + +#Extract omsbundle +$TMPDIR/omsagent-*.universal.x64.sh --extract +mv $TMPDIR/omsbundle* $TMPDIR/omsbundle +#Install omi +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omi*.deb + +#Install scx +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/scx*.deb +#$TMPDIR/omsbundle/bundles/scx-1.6.*-*.universal.x64.sh --install + +#Install omsagent and omsconfig + +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsagent*.deb +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsconfig*.deb +#/$TMPDIR/omsbundle/oss-kits/docker-cimprov-1.0.0-*.x86_64.sh --install +#Use downloaded docker-provider instead of the bundled one + +/$TMPDIR/docker-cimprov-1.0.0-*.x86_64.sh --install + +rm -rf $TMPDIR/omsbundle +rm -f $TMPDIR/omsagent*.sh +rm -f $TMPDIR/docker-cimprov*.sh diff --git a/1.8.1-256/Dockerfile b/1.8.1-256/Dockerfile new file mode 100644 index 00000000..24bc5738 --- /dev/null +++ b/1.8.1-256/Dockerfile @@ -0,0 +1,11 @@ +FROM ubuntu:16.04 +MAINTAINER OMSContainers@microsoft.com +LABEL vendor=Microsoft\ Corp \ +com.microsoft.product="OMS Container Docker Provider" \ +com.microsoft.version="1.0.0-33" +ENV tmpdir /opt +RUN /usr/bin/apt-get update && /usr/bin/apt-get install -y libc-bin wget openssl curl sudo python-ctypes sysv-rc net-tools rsyslog cron vim dmidecode apt-transport-https && rm -rf /var/lib/apt/lists/* +COPY setup.sh main.sh $tmpdir/ +WORKDIR ${tmpdir} +RUN chmod 775 $tmpdir/*.sh; sync; $tmpdir/setup.sh +CMD [ "/opt/main.sh" ] diff --git a/1.8.1-256/main.sh b/1.8.1-256/main.sh new file mode 100644 index 00000000..ee7d0148 --- /dev/null +++ b/1.8.1-256/main.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf +sed -i -e 's/bind 127.0.0.1/bind 0.0.0.0/g' /etc/opt/microsoft/omsagent/sysconf/omsagent.d/syslog.conf +sed -i -e 's/^exit 101$/exit 0/g' /usr/sbin/policy-rc.d + +#Using the get_hostname for hostname instead of the host field in syslog messages +sed -i.bak "s/record\[\"Host\"\] = hostname/record\[\"Host\"\] = OMS::Common.get_hostname/" /opt/microsoft/omsagent/plugin/filter_syslog.rb + +#using /var/opt/microsoft/docker-cimprov/state instead of /var/opt/microsoft/omsagent/state since the latter gets deleted during onboarding +mkdir -p /var/opt/microsoft/docker-cimprov/state +if [[ "$KUBERNETES_SERVICE_HOST" ]];then + #kubernetes treats node names as lower case + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name'].lower()" > /var/opt/microsoft/docker-cimprov/state/containerhostname + #dump kubernetes version to a file for telemetry purpose + curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://$KUBERNETES_SERVICE_HOST/api/v1/nodes | python -c "import sys, json; data=json.load(sys.stdin); kubeletversion = data['items'][0]['status']['nodeInfo']['kubeletVersion']; print kubeletversion;" > /var/opt/microsoft/docker-cimprov/state/kubeletversion + cat /var/opt/microsoft/docker-cimprov/state/kubeletversion +else + curl --unix-socket /var/run/docker.sock "http:/info" | python -c "import sys, json; print json.load(sys.stdin)['Name']" > /var/opt/microsoft/docker-cimprov/state/containerhostname +fi +#check if file was written successfully +cat /var/opt/microsoft/docker-cimprov/state/containerhostname + +#dump OMS agent Image tag for telemetry purpose +#step-1 dump the oms agent container imageID + curl --unix-socket /var/run/docker.sock "http:/containers/json" | python -c "import sys, json; data=json.load(sys.stdin); omscontainer=[item for item in data if item['Image'].startswith('microsoft/oms@sha256:')]; print omscontainer[0]['ImageID'];" > /var/opt/microsoft/docker-cimprov/state/omscontainerimageid + cat /var/opt/microsoft/docker-cimprov/state/omscontainerimageid +#step-2 dump the oms agent repo tags from imageID to be picked up by telemetry + if [ -e "/var/opt/microsoft/docker-cimprov/state/omscontainerimageid" ]; then + curl --unix-socket /var/run/docker.sock "http:/images/json" | python -c "import sys, json; data=json.load(sys.stdin); imageID = open('/var/opt/microsoft/docker-cimprov/state/omscontainerimageid', 'r').read().encode('ascii','ignore'); omscontainer=[item for item in data if imageID.rstrip('\n') in item['Id']]; print omscontainer[0]['RepoTags'];" > /var/opt/microsoft/docker-cimprov/state/omscontainertag + cat /var/opt/microsoft/docker-cimprov/state/omscontainertag + fi + +#Commenting it for test. We do this in the installer now. +#Setup sudo permission for containerlogtailfilereader +#chmod +w /etc/sudoers.d/omsagent +#echo "#run containerlogtailfilereader.rb for docker-provider" >> /etc/sudoers.d/omsagent +#echo "omsagent ALL=(ALL) NOPASSWD: /opt/microsoft/omsagent/ruby/bin/ruby /opt/microsoft/omsagent/plugin/containerlogtailfilereader.rb *" >> /etc/sudoers.d/omsagent +#chmod 440 /etc/sudoers.d/omsagent + +#Disable dsc +/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable +rm -f /etc/opt/microsoft/omsagent/conf/omsagent.d/omsconfig.consistencyinvoker.conf + +#service omid start +/opt/omi/bin/omiserver -s +/opt/omi/bin/omiserver --configfile=/etc/opt/omi/conf/omiserver.conf -d + +if [ -z $INT ]; then + if [ -a /etc/omsagent-secret/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` -d `cat /etc/omsagent-secret/DOMAIN` + elif [ -a /etc/omsagent-secret/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /etc/omsagent-secret/WSID` -s `cat /etc/omsagent-secret/KEY` + elif [ -a /run/secrets/DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` -d `cat /run/secrets/DOMAIN` + elif [ -a /run/secrets/WSID ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w `cat /run/secrets/WSID` -s `cat /run/secrets/KEY` + elif [ -z $DOMAIN ]; then + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY + else + /opt/microsoft/omsagent/bin/omsadmin.sh -w $WSID -s $KEY -d $DOMAIN + fi +else + echo WORKSPACE_ID=$WSID > /etc/omsagent-onboard.conf + echo SHARED_KEY=$KEY >> /etc/omsagent-onboard.conf + /opt/microsoft/omsagent/bin/omsadmin.sh +fi + +#Hack for omi upgrade + + /opt/omi/bin/omicli id + /opt/omi/bin/omicli ei root/cimv2 Container_HostInventory + +#start cron daemon for logrotate +service cron start + +#check if agent onboarded successfully +/opt/microsoft/omsagent/bin/omsadmin.sh -l + +#get omsagent and docker-provider versions +dpkg -l | grep omi | awk '{print $2 " " $3}' +dpkg -l | grep omsagent | awk '{print $2 " " $3}' +dpkg -l | grep docker-cimprov | awk '{print $2 " " $3}' + + +shutdown() { + /opt/omi/bin/service_control stop + /opt/microsoft/omsagent/bin/service_control stop + } + +trap "shutdown" SIGTERM + +sleep inf & wait diff --git a/1.8.1-256/setup.sh b/1.8.1-256/setup.sh new file mode 100644 index 00000000..6df364b2 --- /dev/null +++ b/1.8.1-256/setup.sh @@ -0,0 +1,32 @@ +TMPDIR="/opt" +cd $TMPDIR + +wget https://github.com/Microsoft/OMS-Agent-for-Linux/releases/download/OMSAgent_v1.8.1.256/omsagent-1.8.1-256.universal.x64.sh + +#create file to disable omi service startup script +touch /etc/.omi_disable_service_control +wget https://github.com/Microsoft/Docker-Provider/releases/download/1.0.0-33/docker-cimprov-1.0.0-33.universal.x86_64.sh +chmod 775 $TMPDIR/*.sh + +#Extract omsbundle +$TMPDIR/omsagent-*.universal.x64.sh --extract +mv $TMPDIR/omsbundle* $TMPDIR/omsbundle +#Install omi +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omi*.deb + +#Install scx +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/scx*.deb +#$TMPDIR/omsbundle/bundles/scx-1.6.*-*.universal.x64.sh --install + +#Install omsagent and omsconfig + +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsagent*.deb +/usr/bin/dpkg -i $TMPDIR/omsbundle/100/omsconfig*.deb +#/$TMPDIR/omsbundle/oss-kits/docker-cimprov-1.0.0-*.x86_64.sh --install +#Use downloaded docker-provider instead of the bundled one + +/$TMPDIR/docker-cimprov-1.0.0-*.x86_64.sh --install + +rm -rf $TMPDIR/omsbundle +rm -f $TMPDIR/omsagent*.sh +rm -f $TMPDIR/docker-cimprov*.sh diff --git a/Alerting/NotReadyQuery.md b/Alerting/NotReadyQuery.md new file mode 100644 index 00000000..67cc2f37 --- /dev/null +++ b/Alerting/NotReadyQuery.md @@ -0,0 +1,24 @@ +``` +let endDateTime = now(); +let startDateTime = ago(1h); +let trendBinSize = 1m; +let clusterName = 'YOURCLUSTERNAME'; //can remove references for this from the query to show data for all clusters +KubeNodeInventory +| where TimeGenerated < endDateTime +| where TimeGenerated >= startDateTime +| where ClusterName == clusterName +| distinct ClusterName, TimeGenerated +| summarize ClusterSnapshotCount = count() by Timestamp = bin(TimeGenerated, trendBinSize), ClusterName +| join hint.strategy=broadcast ( + KubeNodeInventory + | where TimeGenerated < endDateTime + | where TimeGenerated >= startDateTime + | summarize TotalCount = count(), ReadyCount = sumif(1, Status contains ('Ready')) + by ClusterName, Timestamp = bin(TimeGenerated, trendBinSize) + | extend NotReadyCount = TotalCount - ReadyCount +) on ClusterName, Timestamp +| project Timestamp, + ReadyCount = todouble(ReadyCount) / ClusterSnapshotCount, + NotReadyCount = todouble(NotReadyCount) / ClusterSnapshotCount +| summarize AggregatedValue = avg(NotReadyCount) by bin(Timestamp, trendBinSize) +``` diff --git a/Alerting/PendingPodCount.md b/Alerting/PendingPodCount.md new file mode 100644 index 00000000..2fc79c93 --- /dev/null +++ b/Alerting/PendingPodCount.md @@ -0,0 +1,33 @@ +``` +let endDateTime = now(); + let startDateTime = ago(1h); + let trendBinSize = 1m; + let clusterName = 'YOURCLUSTERNAME'; + KubePodInventory + | where TimeGenerated < endDateTime + | where TimeGenerated >= startDateTime + | where ClusterName == clusterName + | distinct ClusterName, TimeGenerated + | summarize ClusterSnapshotCount = count() by bin(TimeGenerated, trendBinSize), ClusterName + | join hint.strategy=broadcast ( + KubePodInventory + | where TimeGenerated < endDateTime + | where TimeGenerated >= startDateTime + | distinct ClusterName, Computer, PodUid, TimeGenerated, PodStatus + | summarize TotalCount = count(), + PendingCount = sumif(1, PodStatus =~ 'Pending'), + RunningCount = sumif(1, PodStatus =~ 'Running'), + SucceededCount = sumif(1, PodStatus =~ 'Succeeded'), + FailedCount = sumif(1, PodStatus =~ 'Failed') + by ClusterName, bin(TimeGenerated, trendBinSize) + ) on ClusterName, TimeGenerated + | extend UnknownCount = TotalCount - PendingCount - RunningCount - SucceededCount - FailedCount + | project TimeGenerated, + TotalCount = todouble(TotalCount) / ClusterSnapshotCount, + PendingCount = todouble(PendingCount) / ClusterSnapshotCount, + RunningCount = todouble(RunningCount) / ClusterSnapshotCount, + SucceededCount = todouble(SucceededCount) / ClusterSnapshotCount, + FailedCount = todouble(FailedCount) / ClusterSnapshotCount, + UnknownCount = todouble(UnknownCount) / ClusterSnapshotCount +| summarize AggregatedValue = avg(PendingCount) by bin(TimeGenerated, trendBinSize) +``` diff --git a/Alerting/README.md b/Alerting/README.md new file mode 100644 index 00000000..e535680c --- /dev/null +++ b/Alerting/README.md @@ -0,0 +1,26 @@ +# How to set up alerts for performance problems in Azure Monitor for containers + +Azure Monitor for containers monitors the performance of container workloads deployed to either Azure Container Instances or managed Kubernetes clusters hosted on Azure Kubernetes Service (AKS). To enable monitoring, you will need to first create alert rules using kusto queries. This article will provide information on how to create alert rules with sample alerting queries. + +### How to create alert rules +For step by step procedures on how to create alert rules, please go [here.](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-alerts#create-alert-rule) + +### Alerting situations (Queries): +- [Node CPU and memory utilization exceeds your defined threshold](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-alerts#resource-utilization-log-search-queries) +- [Pod CPU or memory utilization within a controller exceeds your defined threshold as compared to the set limit](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-alerts#resource-utilization-log-search-queries) +- ["NotReady" Status Node counts](NotReadyQuery.md) +- [Pod phase counts (Failed, Pending, Unkown, Running, Succeeded)](PendingPodCount.md) + +#### *Note on the queries* +- Make sure to change the cluster name to your cluster. +```let clusterName = 'YOURCLUSTERNAME';``` + +- *Alert by Pod Phases:* To alert on certain pod phases such as Pending, Failed, or Unknown, you will need to modify the last line of the query in [Pod phase counts](PendingPodCount.md). + For example) Alert on FailedCount +```| summarize AggregatedValue = avg(FailedCount) by bin(TimeGenerated, trendBinSize) ``` + +- *View in Chart*: If you want to see what the query does in the chart, go to Log Analytics and replace the last line that starts with ```| summarize ...``` to ```| render timechart```. Also you can change the start date time and duration by modifying the following: +``` +let startDateTime = startofday(ago(14d)); +let trendBinSize = 1d; +``` diff --git a/Kubernetes/README.md b/Kubernetes/README.md index b804bdd8..db9e267c 100644 --- a/Kubernetes/README.md +++ b/Kubernetes/README.md @@ -49,7 +49,8 @@ Copy file to your master node and run WSID: 36 bytes KEY: 88 bytes ``` - + - Copy the daemon-set yaml "omsagent-ds-secrets.yaml" to your host. + - Create your omsagent daemon-set by running ``` kubectl create -f omsagent-ds-secrets.yaml ``` 2. Check to see whether the OMS Agent daemon-set is running fine. diff --git a/Kubernetes/omsagent-ds-secrets.yaml b/Kubernetes/omsagent-ds-secrets.yaml index 41e72a65..a4e6f111 100644 --- a/Kubernetes/omsagent-ds-secrets.yaml +++ b/Kubernetes/omsagent-ds-secrets.yaml @@ -36,7 +36,7 @@ spec: - mountPath: /etc/omsagent-secret name: omsagent-secret readOnly: true - - mountPath: /var/lib/docker/containers + - mountPath: /var/lib/docker/containers name: containerlog-path livenessProbe: exec: diff --git a/Kubernetes/windows/ws-omsagent-de-secrets.yaml b/Kubernetes/windows/ws-omsagent-de-secrets.yaml index a841a8a8..fd7d279e 100644 --- a/Kubernetes/windows/ws-omsagent-de-secrets.yaml +++ b/Kubernetes/windows/ws-omsagent-de-secrets.yaml @@ -29,7 +29,7 @@ spec: - mountPath: /etc/omsagent-secret name: omsagent-secret readOnly: true - - mountPath: /var/lib/docker/containers + - mountPath: /var/lib/docker/containers name: containerlog-path livenessProbe: exec: diff --git a/OpenShift/ocp-ds-omsagent.yaml b/OpenShift/ocp-ds-omsagent.yaml index 814135a6..acfb7e62 100644 --- a/OpenShift/ocp-ds-omsagent.yaml +++ b/OpenShift/ocp-ds-omsagent.yaml @@ -33,6 +33,8 @@ spec: - mountPath: /etc/omsagent-secret name: omsagent-secret readOnly: true + - mountPath: /var/lib/docker/containers + name: containerlog-path livenessProbe: exec: command: @@ -48,3 +50,6 @@ spec: - name: omsagent-secret secret: secretName: omsagent-secret + - name: containerlog-path + hostPath: + path: /var/lib/docker/containers diff --git a/OpenShift/ocp-omsagent.yaml b/OpenShift/ocp-omsagent.yaml index d442b511..0a5b50b9 100644 --- a/OpenShift/ocp-omsagent.yaml +++ b/OpenShift/ocp-omsagent.yaml @@ -35,6 +35,8 @@ spec: volumeMounts: - mountPath: /var/run/docker.sock name: docker-sock + - mountPath: /var/lib/docker/containers + name: containerlog-path livenessProbe: exec: command: @@ -47,3 +49,6 @@ spec: - name: docker-sock hostPath: path: /var/run/docker.sock + - name: containerlog-path + hostPath: + path: /var/lib/docker/containers diff --git a/README.md b/README.md index 4548317c..47ba91f0 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,14 @@ This set up provides a containerized Container Solution Agent (OMS Agent for Lin - Start the OMS container: ``` -$>sudo docker run --privileged -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log -e WSID="your workspace id" -e KEY="your key" -p 127.0.0.1:25225:25225 -p 127.0.0.1:25224:25224/udp --name="omsagent" -h=`hostname` --restart=always microsoft/oms +$>sudo docker run --privileged -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log -v /var/lib/docker/containers:/var/lib/docker/containers -e WSID="your workspace id" -e KEY="your key" -p 127.0.0.1:25225:25225 -p 127.0.0.1:25224:25224/udp --name="omsagent" -h=`hostname` --restart=always microsoft/oms ``` ### To use OMS for all containers on a container host for FairFax OMS Workspace - Start the OMS container on FairFax OMS workspace: ``` -$>sudo docker run --privileged -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log -e WSID="your workspace id" -e KEY="your key" -e DOMAIN="opinsights.azure.us" -p 127.0.0.1:25225:25225 -p 127.0.0.1:25224:25224/udp --name="omsagent" -h=`hostname` --restart=always microsoft/oms +$>sudo docker run --privileged -d -v /var/run/docker.sock:/var/run/docker.sock -v /var/log:/var/log -v /var/lib/docker/containers:/var/lib/docker/containers -e WSID="your workspace id" -e KEY="your key" -e DOMAIN="opinsights.azure.us" -p 127.0.0.1:25225:25225 -p 127.0.0.1:25224:25224/udp --name="omsagent" -h=`hostname` --restart=always microsoft/oms ``` ### If you are switching from the installed agent to the container diff --git a/Swarmmode/README.md b/Swarmmode/README.md index dc3065a0..aa2b766c 100644 --- a/Swarmmode/README.md +++ b/Swarmmode/README.md @@ -1,5 +1,5 @@ To run OMS Agent as a global service on Docker Swarm, please log onto your master node and run the following command: ``` -docker service create --name omsagent --mode global --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock -e WSID="" -e KEY="" -p 25225:25225 -p 25224:25224/udp --restart-condition=on-failure microsoft/oms +docker service create --name omsagent --mode global --mount type=bind,source=/var/run/docker.sock,destination=/var/run/docker.sock --mount type=bind,source=/var/lib/docker/containers,destination=/var/lib/docker/containers -e WSID="" -e KEY="" -p 25225:25225 -p 25224:25224/udp --restart-condition=on-failure microsoft/oms ```