Search code examples
elasticsearchelkpacketbeat

Packetbeat interface detection


I'm using packbeat to monitor network traffic for a SIEM-like setup with ELK. I'd like to push it to a large number of machines but the setup requires manual identification in packetbeat.yml.

Has any been able to script the process of selecting the appropriate interface to monitor for packetbeat?


Solution

  • Powershell version -

    $count = (C:\path\to\packetbeat.exe - devices).count
    
    $line = ''
    
    
    for($i=0; $i -le ($count-1); $i++){
    
        $line +="packetbeat.interfaces.device:"+" $i `r`n" 
    
        }
    
    $line  | Out-File -FilePath "C:\path\to\packetbeat\Interfaces.yml"
    
    $configTemplate = Get-Content -Path "C:\path\to\packetbeat\ConfigTemplate.yml"
    
    $interfaces = Get-Content -Path "C:\path\to\packetbeat\Interfaces.yml"
    
    $interfaces + "`r`n" + $configTemplate | Out-File -FilePath "C:\path\to\packetbeat\packet.yml"