how can I post elastic search from windows?

0

I am developing a system that will post a log that I have hosted on a virtual server, for now just post the fields that I have not defined and post them in a generic way, the program will also parse it

clear-host
$contenido=Get-Content -Path \"mi direccion host virtual"\log.txt |  Out-String

$obj = @()
foreach($line in ($contenido)){

    $nline = $line.Split(",") #-replace """",""
    $properties = @{
        'NombreTienda' = $nline[1]
        'NombreUsuario' = $nline[3]
        'NombreEquipo' = $nline[5]
        'VersionSO' = $nline[7]
        'Fecha' = $nline[9]
        'NumeroPOS'= $nline[11]
        'Accion' = $nline[13]
    }

    $obj += New-Object PSObject -Property $properties

}

$obj


Invoke-RestMethod -Method POST -uri ""miuri"/logs" -Body '{"$obj"}' -ContentType 'application/json'
    
asked by Matias Arriagada 18.07.2018 в 16:45
source

1 answer

0

I found the error close

clear-host

$ content = Get-Content -Path \ "mirepository" \ log.txt foreach ($ line in ($ content)) {

$nline = $line.Split(",")
$properties = New-Object PSObject -Property @{
    'NombreTienda' = $nline[1]
    'NombreUsuario' = $nline[3]
    'NombreEquipo' = $nline[5]
    'VersionSO' = $nline[7]
    'Fecha' = $nline[9]
    'NumeroPOS'= $nline[11]
    'Accion' = $nline[13]
}

$json = $properties | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method POST -uri ""mikibana"\logs" -Body $json -ContentType 'application/json'

}

    
answered by 19.07.2018 / 18:50
source