Skip to content

Instantly share code, notes, and snippets.

@tukanuk
Last active August 12, 2022 20:23
Show Gist options
  • Save tukanuk/0683ad423210c531c45280993b0cdaca to your computer and use it in GitHub Desktop.
Save tukanuk/0683ad423210c531c45280993b0cdaca to your computer and use it in GitHub Desktop.
OneAgent Local API and Metric Scripting Integration Examples
$Params = @{
Method = "Post"
Uri = "http://localhost:14499/metrics/ingest"
Body = "test.temperature,sensor=basement 15"
ContentType = "text/plain; charset=utf-8"
}
Invoke-RestMethod @Params
# For more info see:
# https://www.dynatrace.com/support/help/extend-dynatrace/extend-metrics/ingestion-methods/oneagent-metric-api
# You will be prompted to enter for the user password
Get-WmiObject -Query 'SELECT DeviceID, FreeSpace, Size FROM Win32_LogicalDisk' -ComputerName <ip-address> \
-Credential <full-user-name> | Format-Table -p DeviceID, FreeSpace, Size
# If you are able to sucessfully execute this command from an ActiveGate to a remote host,
# you should be able to remotely monitor a Window's host with a WMI Extension.
# For more info on proper configuration see:
# https://www.dynatrace.com/support/help/extend-dynatrace/extensions20/data-sources/wmi-extensions
# Basic Metric Scripting Integration
$query = 'SELECT DeviceID, FreeSpace, Size FROM Win32_LogicalDisk'
$WMIObject = Get-WMIObject -Query $query
echo "test.free_space,deviceid=$($WMIObject.deviceid) $($WMIObject.freespace)" | .\dynatrace_ingest -v
# For more info see:
# https://www.dynatrace.com/support/help/extend-dynatrace/extend-metrics/ingestion-methods/oneagent-pipe
# https://www.dynatrace.com/support/help/extend-dynatrace/extend-metrics/reference/metric-ingestion-protocol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment