-
Notifications
You must be signed in to change notification settings - Fork 49
ElasticSearch
Massimo Bonvicini edited this page Aug 27, 2019
·
2 revisions
> Add-LoggingTarget -Name ElasticSearch -Configuration @{
ServerName = <NOTSET> # <Required> Sets the ES server name (eg. 'localhost')
ServerPort = <NOTSET> # <Required> Sets the ES server port (eg. 9200)
Index = <NOTSET> # <Required> Sets the ES index name to log to (eg. 'logs-%{+%Y.%m.%d}')
# It supports templating like $Logging.Format
Type = <NOTSET> # <Required> Sets the ES type for the message (eg. 'log')
Level = <NOTSET> # <Not required> Sets the logging format for this target
Flatten = $false # <Not required> Transforms the log hashtable in a 1-D hashtable
Https = $false # <Not required> Uses HTTPS instead of HTTP in elasticsearch URL if $true
Authorization = <NOTSET> # <Not required> Converts creds to base64 and adds it to headers. (eg. 'username:password')
}
$Body = @{source = 'Logging'; host='bastion.constoso.com'; _metadata = @{ip = '10.10.10.10'; server_farm = 'WestEurope'}}
Write-Log -Level 'WARNING' -Message 'Hello, Powershell!' -Body $Body
{
"_index": "powershell-2018-05-10",
"_type": "doc",
"_id": "6BfJXWMB8moSvzgSbZgo",
"_score": 1,
"_source": {
"body": {
"host": "bastion.constoso.com",
"_metadata": {
"server_farm": "WestEurope",
"ip": "10.10.10.10"
},
"source": "Logging"
},
"levelno": 30,
"timestamp": "2018-05-14T10:34:31+02",
"level": "WARNING",
"message": "Hello, Powershell, No Flatten"
}
}
{
"_index": "powershell-2018-05-10",
"_type": "doc",
"_id": "6RfJXWMB8moSvzgSeJj_",
"_score": 1,
"_source": {
"source": "Logging",
"server_farm": "WestEurope",
"ip": "10.10.10.10",
"levelno": 30,
"level": "WARNING",
"host": "bastion.constoso.com",
"message": "Hello, Powershell, Flatten",
"timestamp": "2018-05-14T10:34:34+02"
}
}