Create a timestamp suitable for Loki log entries (Unix Epoch in nanoseconds).
Get-LokiTimestamp [[-Timestamp] <String>] [[-Date] <DateTime>] [[-AddSeconds] <Int32>] [<CommonParameters>]
Calling this function will return a timestamp suitable for Loki: - If a timestamp is provided it will be parsed and converted. - If no timestamp is provided the current date/time will be used.
$timestamp = Get-LokiTimestamp
Write-Host "Current Unix Epoch is: $timestamp"
$timestamp = Get-LokiTimestamp -Timestamp '2022-09-07T14:51:57Z'
Write-Host "Unix Epoch for 2022-09-07T14:51:57Z is: $timestamp"
$timestamp = Get-LokiTimestamp -Timestamp '1662562317000000000'
Write-Host "Unix Epoch for 1662562317000000000 is, you guessed it...: $timestamp"
$timestamp = Get-LokiTimestamp -Date $([DateTime]::Parse('2022-09-07T14:51:57Z'))
Write-Host "Unix Epoch for 2022-09-07T14:51:57Z is: $timestamp"
Specifies the timstamp to parse, if provided.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the date to parse, if provided.
Type: DateTime
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
Specifies the number of seconds to add to the timestamp. The value can be negative or positive.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.