https://github.com/jahands/axiom-powershell
A PowerShell module for axiom.co
https://github.com/jahands/axiom-powershell
powershell powershell-module
Last synced: 10 months ago
JSON representation
A PowerShell module for axiom.co
- Host: GitHub
- URL: https://github.com/jahands/axiom-powershell
- Owner: jahands
- License: mit
- Created: 2023-08-16T08:45:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-18T13:56:06.000Z (over 2 years ago)
- Last Synced: 2025-04-02T13:19:24.784Z (10 months ago)
- Topics: powershell, powershell-module
- Language: PowerShell
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# axiom-powershell
A PowerShell module for [Axiom.co](https://axiom.co/)
## Examples
### Log a message
```powershell
Import-Module $PSScriptRoot/AxiomLogger.psm1
$logger = New-AxiomLogger `
-ApiToken $env:AXIOM_TOKEN `
-DataSetName 'mini-backups' `
-Tags @{
"server" = "mini"
"source" = "backup.ps1"
}
# Optionally set custom flush settings
$logger.FlushAfterSeconds(5) # default 10
$logger.FlushAfterLogs(10) # Default 20
# Log some data
$logger.Log(@{
"message" = "Backup started"
"level" = "info"
})
# ... do some work
$logger.Flush() # Flush remaining logs
```
### Pipe rclone logs into Axiom
```powershell
Import-Module $PSScriptRoot/AxiomLogger.psm1
rclone --use-json-log copy ./ ../tmp --dry-run 2>&1 | ForEach-Object {
if ($_.ToString().StartsWith('{"level":')) {
# Send json logs directly to Axiom
$logger.Log((ConvertFrom-Json $_))
} else {
# Send non-json logs as info
$logger.Log(@{
"msg" = $_
"level" = "info"
})
}
}