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

Adding TimeStamp removes Field.Value. #79

Open
DezzardHD opened this issue Sep 22, 2021 · 0 comments
Open

Adding TimeStamp removes Field.Value. #79

DezzardHD opened this issue Sep 22, 2021 · 0 comments

Comments

@DezzardHD
Copy link

DezzardHD commented Sep 22, 2021

Hey,
I've found that assigning DateTime.Now to info.Timestamp the field.Value is not getting written to InfluxDB2.0 using the v1 compatibility API. (Only tagKeyValue-Pairs and fieldKey appears in InfluxDB)
When I do not assign the TimeStamp, then the value of the field is beeing written.

Debug log of InfluxDB2.0 for writing:
2021-09-22T20:30:45.520092Z debug Request {"log_id": "0Wko35_G000", "service": "http", "method": "POST", "host": "localhost:8086", "path": "/write", "query": "consistency=all&db=myDatabaseName&precision=ns", "proto": "HTTP/1.1", "status_code": 204, "response_size": 0, "content_length": 38, "referrer": "", "remote": "[::1]:61889", "user_agent": "unknown", "took": "50.035ms"}

My problematic #code:

    public async Task writeDynamicRowsToDataBase(string measurementTableName, string[] fieldKeys, string[,] tagKeyValuePair, double value)
    {
        var client = new InfluxClient(new Uri("http://" + this.IP.Value + ":" + this.Port.Value), this.username.Value, this.password.Value);
        var infos = CreateDynamicRowsStartingAt(this.schedulerService.Now, 1, fieldKeys, tagKeyValuePair, value);
        await client.WriteAsync(this.database.Value, measurementTableName, infos);
    }
    private DynamicInfluxRow[] CreateDynamicRowsStartingAt(DateTime timestamp, int rows, string[] fieldKeys,string[,] tagKeyValuePair, double value)
    {
        var infos = new DynamicInfluxRow[rows];
        var info = new DynamicInfluxRow();
        for (int cntFields = 0; cntFields < fieldKeys.GetLength(0); cntFields++)
        {
            info.Fields.Add(fieldKeys[cntFields], value);
        }
        for (int cntTags = 0; cntTags < tagKeyValuePair.GetLength(0); cntTags++)
        {
            info.Tags.Add(tagKeyValuePair[cntTags, 0], tagKeyValuePair[cntTags, 1]);
        }
        info.Timestamp = timestamp;
        infos[0] = info;
        return infos;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant