Question? DataType of Object in InflxDB
By checking the code gound this if clause.
if ($MetricObject.Metrics[$Metric] -isnot [ValueType]) {
$MetricValue = '"' + $MetricObject.Metrics[$Metric] + '"'
}
else {
$MetricValue = $MetricObject.Metrics[$Metric] | Out-InfluxEscapeString
}
"$($MetricObject.Measure | Out-InfluxEscapeString)$TagData $($Metric | Out-InfluxEscapeString)=$MetricValue $timeStampNanoSecs"
Can you explain the $MetricObject.Metrics[$Metric] -isnot [ValueType] part?
By testing, I found out that it checks which data types are used. However, I do not quite understand how
Sorry for the late response. This line is checking if the metric is numeric or not. If its not numeric then it assumes it should be treated as a string and wraps the value in quotation marks.
It works by checking if the value is of type [valuetype]. These are described here: https://learn.microsoft.com/en-us/powershell/scripting/lang-spec/chapter-04?view=powershell-7.3#42-value-types
Its not perfect as a single [char] value is treated as valuetype, but thats a pretty unlikely case in this instance.