Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.
This repository was archived by the owner on May 30, 2019. It is now read-only.

Unix time too long when sending to influxDB #34

Closed

Description

@Rici11

I've noticed that the date that gets sent is 15 characters long, for example: 141882399527883

When sending to InfluxDB this results in an error such as this:
GraphiteServer:%!(EXTRA *strconv.NumError=strconv.ParseUint: parsing "141882399527883": value out of range).

A correct unix time would normally be 10 characters long, such as 1418823995
which in turn would result in:
$ date --date='@1418823995'
Wed Dec 17 13:46:35 UTC 2014

I'm guessing that you're adding microseconds or something to the output, in that case the number should be decimal such as:

$ date --date='@1418823995.27883'
Wed Dec 17 13:46:35 UTC 2014

Do we really need microseconds in the output date? Any ideas on how to change the date to make it epoch time accurate to the second or decimal and thus allow compatibility with the InfluxDB storage engine?

Thanks!

Steps to reproduce:

  1. Enable input_graphite to InfluxDB by changing this part in /opt/influxdb/shared/config.toml

Configure the graphite api

[input_plugins.graphite]
enabled = true
port = 2003
database = "graphite_db"
2. Direct Graphite-PowerShell metrics to InfluxDB
3. tail -f /opt/influxdb/shared/log.txt

Activity

  1. bonobo78 commented on Dec 22, 2014

    @bonobo78

    reproduced with same scenario.

    parsing "14192584153982": value out of range

    edit:
    temporary solve this issue by dividing the value of the timestamp by 100000 before sending it.

  2. enricnes commented on Feb 10, 2015

    @enricnes

    For some reason, in Send-BulkGraphiteMetrics.ps1, you need to add ".ToString()" to this statement:
    [uint64]$UnixTime = (Get-Date -Date $utcDate -UFormat %s) after $utcDate.
    It would be:
    [uint64]$UnixTime = (Get-Date -Date $utcDate.ToString() -UFormat %s)

    We also commented this section:
    [Parameter(Mandatory = $true,
    ParameterSetName = 'Epoch / Unix Time')]
    [ValidateRange(1, 99999999999999)]
    [string]$UnixTime,

  3. MattHodge commented on Feb 12, 2015

    @MattHodge
    Owner

    Can you all please try the following and let me know if you have success:

    1. Make sure you are running the latest version (v1.2.0)
    2. Open Send-BlukGraphiteMetrics.ps1 in text editor
    3. Change line 75

    from:
    [uint64]$UnixTime = (Get-Date -Date $utcDate -UFormat %s)

    to:
    [int]$UnixTime = [math]::Round((Get-Date -Date $utcDate -UFormat %s))

    If you have success please let me know and I will release this with some InfluxDB documentation.

  4. marconfus commented on Feb 13, 2015

    @marconfus

    The problem is that on some locales Get-Date returns a string with a "," instead of a "." as decimal point (in german for example). Make a string replace "," to "." and it works.

  5. dillten commented on Feb 16, 2015

    @dillten

    Based on this, seems like the most invariant fix to this would be:
    [uint64]$UnixTime = [double]::Parse((Get-Date -Date $utcDate -UFormat %s))

  6. toni-moreno commented on Feb 19, 2015

    @toni-moreno

    Hi. We have the same issue on sending data to graphite.

    There is any official fix for that ?

    Lot of thanks!

  7. tbolon commented on Feb 23, 2015

    @tbolon

    I can confirm that it caused errors too in our case (french regional settings on our server).

    Graphite was reporting errors:

    23/02/2015 14:40:28 :: Error writing to /opt/graphite/storage/whisper/local/internal/xxx/sqlserver/locks/database/averagewaittime/ms.wsp
    23/02/2015 14:40:28 :: Unhandled Error
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 207, in _worker
        result = context.call(ctx, function, *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
        return self.currentContext().callWithContext(ctx, func, *args, **kw)
      File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
        return func(*args,**kw)
      File "/opt/graphite/lib/carbon/writer.py", line 158, in writeForever
        writeCachedDataPoints()
    --- <exception caught here> ---
      File "/opt/graphite/lib/carbon/writer.py", line 137, in writeCachedDataPoints
        whisper.update_many(dbFilePath, datapoints)
      File "/usr/local/lib/python2.7/dist-packages/whisper.py", line 577, in update_many
        return file_update_many(fh, points)
      File "/usr/local/lib/python2.7/dist-packages/whisper.py", line 611, in file_update_many
        __archive_update_many(fh,header,currentArchive,currentPoints)
      File "/usr/local/lib/python2.7/dist-packages/whisper.py", line 635, in __archive_update_many
        currentString += struct.pack(pointFormat,interval,value)
    struct.error: 'L' format requires 0 <= number <= 4294967295
    

    We have used the code suggested by @dillten

  8. rgunst commented on Feb 23, 2015

    @rgunst

    Same problem here. For me the suggestion from @dillten worked.

  9. MattHodge commented on Feb 24, 2015

    @MattHodge
    Owner

    Thanks @dillten, I will implement this and release a new version.

  10. added a commit that references this issue on Feb 25, 2015
  11. MattHodge commented on Feb 25, 2015

    @MattHodge
    Owner

    Fixed in Graphite-PowerShell v1.2.1.

    Thanks for reporting the issue! Thanks @dillten for the fix.

  12. MattHodge commented on Feb 25, 2015

    @MattHodge
    Owner

    v1.2.1 had a bug, please grab Graphite-PowerShell v1.2.2 instead.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions