Skip to content

Azure Linux machines

Overview

Azure Virtual Machines service is developed and managed by Microsoft Corp.

Event Categories

The following table lists the data source offered by this integration.

Data Source Description
Authentication logs PAM authentication mechanism
Process command-line parameters Common Linux processes (cron, ssh, sudo)
Process use of network SSH and PAM daemon

Event Samples

Find below few samples of events and how they are normalized by SEKOIA.IO.

{
    "@timestamp": "2019-07-02T13:45:50.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "pam_unix(sudo:auth): conversation failed"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "error"
    },
    "message": "{ \"time\" : \"2019-07-02T13:45:50.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"err\",\"EventTime\" : \"2019-07-02T13:45:50+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:auth): conversation failed\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:45:50Z\"},\"category\" : \"authpriv\",\"level\" : \"err\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:auth",
        "type": "open",
        "outcome": "failure"
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-07-02T13:46:32.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "pam_unix(sudo:auth): auth could not identify password for [omsagent]"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "critical"
    },
    "message": "{ \"time\" : \"2019-07-02T13:46:32.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"crit\",\"EventTime\" : \"2019-07-02T13:46:32+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:auth): auth could not identify password for [omsagent]\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:46:32Z\"},\"category\" : \"authpriv\",\"level\" : \"crit\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "user": {
        "name": "omsagent"
    },
    "action": {
        "name": "sudo:auth",
        "type": "open",
        "outcome": "failure"
    },
    "related": {
        "user": [
            "omsagent"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-06-27T14:50:01.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "(root) CMD (/usr/lib64/sa/sa1 1 1)"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:50:01.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"CROND\",\"pid\" : \"21188\",\"Ignore\" : \"syslog\",\"Facility\" : \"cron\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:50:01+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"(root) CMD (/usr/lib64/sa/sa1 1 1)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:50:01Z\"},\"category\" : \"cron\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "process": {
        "executable": "/usr/lib64/sa/sa1",
        "command_line": "/usr/lib64/sa/sa1 1 1",
        "parent": {
            "pid": 21188
        }
    },
    "user": {
        "name": "root"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-06-27T14:29:01.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "(root) CMD ([ -f /etc/krb5.keytab ] && [ \\( ! -f /etc/opt/omi/creds/omi.keytab \\) -o \\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true)"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:29:01.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"CROND\",\"pid\" : \"16373\",\"Ignore\" : \"syslog\",\"Facility\" : \"cron\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:29:01+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"(root) CMD ([ -f /etc/krb5.keytab ] && [ \\\\( ! -f /etc/opt/omi/creds/omi.keytab \\\\) -o \\\\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\\\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:29:01Z\"},\"category\" : \"cron\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "process": {
        "command_line": "[ -f /etc/krb5.keytab ] && [ \\( ! -f /etc/opt/omi/creds/omi.keytab \\) -o \\( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \\) ] && /opt/omi/bin/support/ktstrip /etc/krb5.keytab /etc/opt/omi/creds/omi.keytab >/dev/null 2>&1 || true",
        "parent": {
            "pid": 16373
        }
    },
    "user": {
        "name": "root"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-06-27T14:50:51.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "Received disconnect from 185.122.161.248 port 39070:11: disconnected by user"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:50:51.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sshd\",\"pid\" : \"14020\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:50:51+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"Received disconnect from 185.122.161.248 port 39070:11: disconnected by user\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:50:51Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "source": {
        "ip": "185.122.161.248",
        "address": "185.122.161.248",
        "port": 39070
    },
    "process": {
        "pid": 14020
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "related": {
        "ip": [
            "185.122.161.248"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-06-27T14:48:18.0000000Z",
    "action": {
        "outcome": "success"
    },
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "omsagent : TTY=unknown ; PWD=/opt/microsoft/omsconfig/Scripts/2.6x-2.7x ; USER=root ; COMMAND=/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:48:18.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"notice\",\"EventTime\" : \"2019-06-27T14:48:18+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"omsagent : TTY=unknown ; PWD=/opt/microsoft/omsconfig/Scripts/2.6x-2.7x ; USER=root ; COMMAND=/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:18Z\"},\"category\" : \"authpriv\",\"level\" : \"notice\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "user": {
        "name": "root"
    },
    "process": {
        "executable": "/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh",
        "working_directory": "/opt/microsoft/omsconfig/Scripts/2.6x-2.7x",
        "command_line": "/opt/microsoft/omsconfig/Scripts/OMSYumUpdates.sh"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-07-02T13:46:15.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "omsagent : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-07-02T13:46:15.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"notice\",\"EventTime\" : \"2019-07-02T13:46:15+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"omsagent : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T13:46:15Z\"},\"category\" : \"authpriv\",\"level\" : \"notice\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "user": {
        "name": "root"
    },
    "process": {
        "executable": "/bin/test",
        "command_line": "/bin/test -r /var/lib/docker/containers/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16/bf64bddcdb7d18a3090980d2539e2c15c924138f489c280871941064850f7d16-json.log",
        "working_directory": "/"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    },
    "action": {
        "outcome": "success"
    }
}
{
    "@timestamp": "2019-06-27T14:48:28.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "pam_unix(sudo:session): session closed for user root"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:48:28.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:48:28+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:session): session closed for user root\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:28Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "user": {
        "name": "root"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:session",
        "type": "close",
        "outcome": "success"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-06-27T14:48:28.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "pam_unix(sudo:session): session opened for user root by (uid=0)"
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-06-27T14:48:28.0000000Z\",\"resourceId\" : \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"sudo\",\"Ignore\" : \"syslog\",\"Facility\" : \"authpriv\",\"Severity\" : \"info\",\"EventTime\" : \"2019-06-27T14:48:28+0000\",\"SendingHost\" : \"localhost\",\"Msg\" : \"pam_unix(sudo:session): session opened for user root by (uid=0)\",\"hostname\" : \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-06-27T14:48:28Z\"},\"category\" : \"authpriv\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "user": {
        "name": "root"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "sudo:session",
        "type": "open",
        "outcome": "success"
    },
    "related": {
        "user": [
            "root"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}
{
    "@timestamp": "2019-07-02T14:15:01.0000000Z",
    "event": {
        "outcome": "success"
    },
    "azure_linux": {
        "message": "Started Session 13124 of user omsagent."
    },
    "log": {
        "hostname": "LinuxRedhatDesktop",
        "level": "info"
    },
    "message": "{ \"time\" : \"2019-07-02T14:15:01.0000000Z\",\"resourceId\": \"/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/demo.sekoia.io/providers/Microsoft.Compute/virtualMachines/LinuxRedhatDesktop\",\"properties\" : {\"ident\" : \"systemd\",\"Ignore\" : \"syslog\",\"Facility\" : \"daemon\",\"Severity\" : \"info\",\"EventTime\" : \"2019-07-02T14:15:01+0000\",\"SendingHost\": \"localhost\",\"Msg\" : \"Started Session 13124 of user omsagent.\",\"hostname\": \"LinuxRedhatDesktop\",\"FluentdIngestTimestamp\" : \"2019-07-02T14:15:01Z\"},\"category\" : \"daemon\",\"level\" : \"info\",\"operationName\" : \"LinuxSyslogEvent\"}",
    "user": {
        "name": "omsagent"
    },
    "os": {
        "family": "linux",
        "platform": "linux"
    },
    "action": {
        "name": "systemd:session",
        "type": "open",
        "outcome": "success"
    },
    "related": {
        "user": [
            "omsagent"
        ]
    },
    "sekoiaio": {
        "intake": {
            "parsing_status": "success"
        }
    }
}

Extracted Fields

The following table lists the fields that are extracted, normalized under the ECS format, analyzed and indexed by the parser. It should be noted that infered fields are not listed.

Name Type Description
@timestamp date Date/time when the event originated.
azure_linux.message keyword None
log.level keyword Log level of the log event.
process.command_line wildcard Full command line that started the process.
process.executable keyword Absolute path to the process executable.
process.parent.pid long Process id.
process.pid long Process id.
process.working_directory keyword The working directory of the process.
source.domain keyword The domain name of the source.
source.ip ip IP address of the source.
source.port long Port of the source.
user.name keyword Short name or login of the user.

Configure

This setup guide will show you how to forward events produced by a Linux Virtual Machine hosted on Azure platform to SEKOIA.IO.

Theses changes have to be made from the Azure Web Portal.

Azure Event Hubs

As a prerequisite, you need to choose an existing “resource group”, or create a new one (e.g. company-resource-group).

Retrieve your Subscription ID

You also need your “Subscription ID” if you don't have a default one. In Azure Web Portal, navigate to: “Home”, “Cost Management + Billing”, ”Subscriptions”. From there, copy the relevant “Subscription ID” that will be used in the command line (e.g. uuid)

Create the Event Hubs

Use Azure PowerShell (within Cloud Shell interface for example) to create a namespace (e.g. company-eventhub) and a specific Event Hub (e.g. linux-event) within your “resource group” (e.g. company-resource-group)

PS Azure:\> az eventhubs namespace create --name company-eventhub --resource-group company-resource-group --enable-kafka true --subscription uuid
PS Azure:\> az eventhubs eventhub create --resource-group company-resource-group --namespace-name company-eventhub --name linux-event --message-retention 3 --partition-count 4 --subscription uuid

Info

Please replace :

  • company-resource-group with the name of your “resource group”.
  • uuid with your subscription ID retrieved previously (see below).

Create “Shared Access Policies”

  1. Navigate to “Home”, “Event Hubs”, “company-eventhub - Shared access policies”. From there, you can create a policy (e.g. RootManageSharedAccessKey) with the claims Manage, Send and Listen, and note the Primary Key that will be used as the SharedAccessKey.
  2. Navigate to “Home”, “Event Hubs”, “company-eventhub”, “linux-event - Shared access policies”. From there, you can create a policy (e.g. sekoiaio) with the claims Listen. Once created, click on the policy and save the Connection string-primary key, to be sent to SEKOIA.IO.
  3. Navigate to “Home”, “Event Hubs”, “company-eventhub”, ”linux-event - Consumer groups”. From there, you can create a consumer group (e.g. sekoiaio).

Create a Blob Storage for Checkpointing

In order to allow SEKOIA.IO keep track of the consumed events, the next step consists in creating a dedicated Azure Blob Storage.

To proceed, you can use Azure PowerShell:

PS Azure:\> az storage account create --name "sekoiaiocheckpoint" --resource-group "company-resource-group"
PS Azure:\> az storage container create --name "linux-event" --account-name "sekoiaiocheckpoint"

Info

The container name, here linux-event should be the same as the Event Hub’s one. You also need to replace company-resource-group with the name of your “resource group”.

Finally, you have to retrieve the connection string from Azure Web Portal by going in “Storage Accounts”, then in the created storage (sekoiaiocheckpoint) and finally in the “Access Keys” section. After clicking on “Show keys”, you can copy the first of the two connection strings.

Linux Virtual Machine

You need to activate and configure the diagnostic extension LinuxDiagnostic.

  1. Navigate to “Home”, “Virtual machines”, “virtual machine name (e.g. company-linux)”, “Settings” and “Extensions”. Install it and note the new StorageAccount name created (e.g. company-storage-account).
  2. Navigate to “Home”, “Storage accounts”, “company-storage-account”, “Access keys”. From there you can note the key value later used as the storageAccountKey.
  3. Navigate to “Home”, “Storage accounts”, “company-storage-account”, “Shared access signature”. From there set the expiration date with caution, then click on “Generate SAS and connection string”. You should note the SAS token value later used (starting with sv?=).

Navigate to “Home”, “All resources”. From there you can note the resourceId associated to your linux virtual machine.

You need to create two configuration files public_settings.json and protected_settings.json.

Once again you need Azure PowerShell to do it using your favorite text editor:

PS Azure:\> vim public_settings.json

Adapt the public settings configuration file with the value of theses variables: StorageAccount, resourceId and sinks and the syslog configuration.

{
  "StorageAccount": "company-storage-account",
  "ladCfg": {
    "diagnosticMonitorConfiguration": {
      "eventVolume": "Medium",
      "metrics": {
        "metricAggregation": [
          {
            "scheduledTransferPeriod": "PT1H"
          },
          {
            "scheduledTransferPeriod": "PT1M"
          }
        ],
        "resourceId": "/subscriptions/128ed5ce-4f50-4b5f-a3b0-08233b5a86b6/resourceGroups/company-resource-group/providers/Microsoft.Compute/virtualMachines/company-linux"
      },
      "performanceCounters": {
        "performanceCounterConfiguration": []
      },
      "syslogEvents": {
        "sinks": "linux-event",
        "syslogEventConfiguration": {
          "LOG_AUTH": "LOG_INFO",
          "LOG_AUTHPRIV": "LOG_INFO",
          "LOG_CRON": "LOG_INFO",
          "LOG_DAEMON": "LOG_INFO",
          "LOG_FTP": "LOG_INFO",
          "LOG_KERN": "LOG_INFO",
          "LOG_LOCAL0": "LOG_INFO",
          "LOG_LOCAL1": "LOG_INFO",
          "LOG_LOCAL2": "LOG_INFO",
          "LOG_LOCAL3": "LOG_INFO",
          "LOG_LOCAL4": "LOG_INFO",
          "LOG_LOCAL5": "LOG_INFO",
          "LOG_LOCAL6": "LOG_INFO",
          "LOG_LOCAL7": "LOG_INFO",
          "LOG_LPR": "LOG_INFO",
          "LOG_MAIL": "LOG_INFO",
          "LOG_NEWS": "LOG_INFO",
          "LOG_SYSLOG": "LOG_INFO",
          "LOG_USER": "LOG_INFO",
          "LOG_UUCP": "LOG_INFO"
        }
      }
    },
    "sampleRateInSeconds": 15
  }
}

You need to generate an authentication token for the access to the linux-event hub. First we'll convert the expiration date we set before into a unix timestamp. Extract the se= value from storageAccountSasTokenvand use it as a parameter to this command:

PS Azure:\> date -d '2021-07-09T23:09:19' +%s
1625872159

Then you could create this python script:

PS Azure:\> vim get_token.py

Adapt theses variables: sb_name, eh_name, Url, sas_name, sas_value, and expiry:

from urllib.parse import quote_plus, quote
import hmac
import hashlib
import base64

def get_auth_token(sb_name, eh_name, sas_name, sas_value, expiry):
    """
    Returns an authorization token dictionary
    for making calls to Event Hubs REST API.
    """
    uri = quote_plus("https://{}.servicebus.windows.net/{}" \
                                  .format(sb_name, eh_name))
    sas = sas_value.encode('utf-8')
    string_to_sign = (uri + '\n' + expiry).encode('utf-8')
    signed_hmac_sha256 = hmac.HMAC(sas, string_to_sign, hashlib.sha256)
    signature = quote(base64.b64encode(signed_hmac_sha256.digest()))
    return  {"sb_name": sb_name,
             "eh_name": eh_name,
             "token":'SharedAccessSignature sr={}&sig={}&se={}&skn={}' \
                     .format(uri, signature, expiry, sas_name)
            }

print(get_auth_token(sb_name="company-eventhub", eh_name="linux-event", sas_name="RootManageSharedAccessKey", sas_value="base64string", expiry="unix_timestamp"))

Execute this python script and note the token variable value only from the sr=.

PS Azure:\> python get_token.py
{'token': 'SharedAccessSignature sr=https%3A%2F%2Fcompany-eventhub.servicebus.windows.net%2Flinux-event&sig=9%2BOwFlfqBVEcVg2c5G1wztIjG22GtsMZN5g4NYEu6p0%3D&se=1561569146&skn=RootManageSharedAccessKey', 'eh_name': 'linux-event', 'sb_name': 'company-eventhub'}

Then edit the protected settings configuration file:

PS Azure:\> vim protected_settings.json

Adapt the public protected settings configuration file with the value of theses variables: storageAccountName, storageAccountSasToken (starting with sv= and previously refered as SAS token), sasURL (replace the different values, company-eventhub, linux-event, sr=, and RootManageSharedAccessKey), and SharedAccessKeyName:

{
    "storageAccountName": "company-storage-account",
    "storageAccountSasToken": "sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-06-21T15:52:44Z&st=2019-06-21T07:52:44Z&spr=https&sig=Dewc7mP63E4xrwqttVcOrChgDIpm6Trp%2FR4dfvSo4vg%3D",
    "sinksConfig": {
        "sink": [
            {
                "name": "SyslogJsonBlob",
                "type": "JsonBlob"
            },
            {
                "name": "linux-event",
                "type": "EventHub",
                "sasURL": "https://company-eventhub.servicebus.windows.net/linux-event?sr=https%3A%2F%2Fcompany-eventhub.servicebus.windows.net%2Flinux-event&sig=W86ldfWlPKW0sutGWM7shYGlg%2BbwnbtyVJ7eMsBs840%3D&se=1561137701&skn=RootManageSharedAccessKey"
            }
        ]
    }
}

Finally you could push the change of the diagnostic extension configuration (adapt the parameters resource-group, vm-name):

PS Azure:\> az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group company-resource-group --vm-name company-linux --protected-settings protected_settings.json --settings public_settings.json --subscription uuid

Forward the Connection Keys to SEKOIA.IO

Finally, please send to SEKOIA.IO the following information:

  • Azure Event Hub’s “Connection string-primary key” (e.g. "Endpoint=sb://company-eventhub.servicebus.windows.net/;SharedAccessKeyName=sekoiaio;SharedAccessKey=XXXXXX;EntityPath=linux-event").
  • Azure Event Hub’s consumer group name (e.g. sekoiaio).
  • Azure Blob Storage’s connection string (e.g. "DefaultEndpointsProtocol=https;AccountName=sekoiaiocheckpoint;AccountKey=XXXXX").

Further Readings

Back to top