Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of datetime and object properties #16

Open
markwragg opened this issue Jan 25, 2019 · 1 comment
Open

Improve handling of datetime and object properties #16

markwragg opened this issue Jan 25, 2019 · 1 comment

Comments

@markwragg
Copy link
Owner

some further suggestions from @Tonic8:

  • if a field in an object is a DateType, you can convert it in something InfluxDB will understand:
(dir | select -first1).lastWriteTime | gm
(dir | select -first1).lastWriteTime | get-date -f "yyyy-MM-dd HH:mm:ss.fff"
(dir | select -first1).lastWriteTime | convertTo-UnixTimeNanoseconds

where fff is millisecond, (talked here https://stackoverflow.com/questions/28589520/how-to-store-dates-in-influxdb) and here https://docs.influxdata.com/influxdb/v1.5/query_language/data_exploration/#time-syntax

  • if a field in an object is something not a "string" but a internal field, like this in Citrix sdk (extract of get-brokerSession | GM):
ConnectionViaIP   NoteProperty string ConnectedViaIP=1.2.3.4
ConnectionMode    NoteProperty Citrix.Broker.Admin.SDK.ConnectionMode ConnectionMode=Brokered
  • if you pass it, the conversion is going wrong(missing doublequote), user must prepare the field, to convert it as string, before passing it to convertTo-Metric
  • example with a Boolean field (it should have double-quote),
    $test = New-Object PSObject -Property @{testBoolean=$True}
  • below the result from the Write-Influx commande in Verbose
    Xendesktop,computer1 testBoolean=true 12345678898

Originally posted by @Tonic8 in #15 (comment)

@Tonic8
Copy link

Tonic8 commented Feb 12, 2019

we can extend the request to any kind of field (except data/time) to set the result tostring()

this could simplify for example, some fields are not strings but can be converted to string...

PS C:\temp> (dir -file | select -First 1).Directory | gm
   TypeName: System.IO.DirectoryInfo

PS C:\temp> (dir -file | select -First 1).Directory.tostring()
C:\temp
PS C:\temp>

PS C:\temp> (dir -file | select -First 1).Directory

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       12/02/2019     20:47                temp

PS C:\temp>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants