Interface IInfluxDBClient
Namespace: InfluxDB3.Client
Assembly: InfluxDB3.Client.dll
Syntax
public interface IInfluxDBClient
Methods
Query(String, Nullable<QueryType>, Nullable<String>, Nullable<Dictionary<String, Object>>, Nullable<Dictionary<String, String>>)
Query data from InfluxDB IOx using FlightSQL.
Declaration
IAsyncEnumerable<object? []> Query(string query, QueryType? queryType = null, string? database = null, Dictionary<string, object>? namedParameters = null, Dictionary<string, string>? headers = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The SQL query string to execute. |
System.Nullable<QueryType> | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<Dictionary<System.String, System.Object>> | namedParameters | Name:Value pairs to use as named parameters for this query. Parameters referenced using '$placeholder' syntax in the query will be substituted with the values provided. The supported types are: string, bool, int, float. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to query request. The headers specified here are preferred over the headers specified in the client configuration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<System.Nullable<System.Object>[]> | Batches of rows |
Examples
The following example shows how to use SQL query with named parameters:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.Query(
query: "SELECT a, b, c FROM my_table WHERE id = $id AND name = $name",
namedParameters: new Dictionary<string, object> { { "id", 1 }, { "name", "test" } }
);
The following example shows how to use custom request headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.Query(
query: "SELECT a, b, c FROM my_table",
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
QueryBatches(String, Nullable<QueryType>, Nullable<String>, Nullable<Dictionary<String, Object>>, Nullable<Dictionary<String, String>>)
Query data from InfluxDB IOx using FlightSQL.
Declaration
IAsyncEnumerable<RecordBatch> QueryBatches(string query, QueryType? queryType = null, string? database = null, Dictionary<string, object>? namedParameters = null, Dictionary<string, string>? headers = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The SQL query string to execute. |
System.Nullable<QueryType> | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<Dictionary<System.String, System.Object>> | namedParameters | Name:Value pairs to use as named parameters for this query. Parameters referenced using '$placeholder' syntax in the query will be substituted with the values provided. The supported types are: string, bool, int, float. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to query request. The headers specified here are preferred over the headers specified in the client configuration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<RecordBatch> | Batches of rows |
Examples
The following example shows how to use SQL query with named parameters:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.QueryBatches(
query: "SELECT a, b, c FROM my_table WHERE id = $id AND name = $name",
namedParameters: new Dictionary<string, object> { { "id", 1 }, { "name", "test" } }
);
The following example shows how to use custom request headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.QueryBatches(
query: "SELECT a, b, c FROM my_table",
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
QueryPoints(String, Nullable<QueryType>, Nullable<String>, Nullable<Dictionary<String, Object>>, Nullable<Dictionary<String, String>>)
Query data from InfluxDB IOx into PointData structure using FlightSQL.
Declaration
IAsyncEnumerable<PointDataValues> QueryPoints(string query, QueryType? queryType = null, string? database = null, Dictionary<string, object>? namedParameters = null, Dictionary<string, string>? headers = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The SQL query string to execute. |
System.Nullable<QueryType> | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<Dictionary<System.String, System.Object>> | namedParameters | Name:Value pairs to use as named parameters for this query. Parameters referenced using '$placeholder' syntax in the query will be substituted with the values provided. The supported types are: string, bool, int, float. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to query request. The headers specified here are preferred over the headers specified in the client configuration. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<PointDataValues> | Batches of rows |
Examples
The following example shows how to use SQL query with named parameters:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.QueryPoints(
query: "SELECT a, b, c FROM my_table WHERE id = $id AND name = $name",
namedParameters: new Dictionary<string, object> { { "id", 1 }, { "name", "test" } }
);
The following example shows how to use custom request headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
var results = client.QueryPoints(
query: "SELECT a, b, c FROM my_table",
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
WritePointAsync(PointData, Nullable<String>, Nullable<WritePrecision>, Nullable<Dictionary<String, String>>, CancellationToken)
Write data to InfluxDB.
Declaration
Task WritePointAsync(PointData point, string? database = null, WritePrecision? precision = null, Dictionary<string, string>? headers = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
PointData | point | Specifies the Data point to write into InfluxDB. The |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<WritePrecision> | precision | The to use for the timestamp in the write API call. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration. |
CancellationToken | cancellationToken | specifies the token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |
Examples
The following example shows how to write a single point with custom headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
await client.WritePointAsync(
point: PointData.Measurement("h2o").SetTag("location", "europe").SetField("level", 2),
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
WritePointsAsync(IEnumerable<PointData>, Nullable<String>, Nullable<WritePrecision>, Nullable<Dictionary<String, String>>, CancellationToken)
Write data to InfluxDB.
Declaration
Task WritePointsAsync(IEnumerable<PointData> points, string? database = null, WritePrecision? precision = null, Dictionary<string, string>? headers = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<PointData> | points | Specifies the Data points to write into InfluxDB. The |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<WritePrecision> | precision | The to use for the timestamp in the write API call. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration. |
CancellationToken | cancellationToken | specifies the token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |
Examples
The following example shows how to write multiple points with custom headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
await client.WritePointsAsync(
points: new[]{
PointData.Measurement("h2o").SetTag("location", "europe").SetField("level", 2),
PointData.Measurement("h2o").SetTag("location", "us-west").SetField("level", 4),
},
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
WriteRecordAsync(String, Nullable<String>, Nullable<WritePrecision>, Nullable<Dictionary<String, String>>, CancellationToken)
Write data to InfluxDB.
Declaration
Task WriteRecordAsync(string record, string? database = null, WritePrecision? precision = null, Dictionary<string, string>? headers = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | record | Specifies the record in InfluxDB Line Protocol. The |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<WritePrecision> | precision | The to use for the timestamp in the write API call. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration. |
CancellationToken | cancellationToken | specifies the token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |
Examples
The following example shows how to write a single record with custom headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
await client.WriteRecordAsync(
record: "stat,unit=temperature value=24.5",
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);
WriteRecordsAsync(IEnumerable<String>, Nullable<String>, Nullable<WritePrecision>, Nullable<Dictionary<String, String>>, CancellationToken)
Write data to InfluxDB.
Declaration
Task WriteRecordsAsync(IEnumerable<string> records, string? database = null, WritePrecision? precision = null, Dictionary<string, string>? headers = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<System.String> | records | Specifies the records in InfluxDB Line Protocol. The |
System.Nullable<System.String> | database | The database to be used for InfluxDB operations. |
System.Nullable<WritePrecision> | precision | The to use for the timestamp in the write API call. |
System.Nullable<Dictionary<System.String, System.String>> | headers | The headers to be added to write request. The headers specified here are preferred over the headers specified in the client configuration. |
CancellationToken | cancellationToken | specifies the token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Task |
Examples
The following example shows how to write multiple records with custom headers:
using var client = new InfluxDBClient(host: "http://localhost:8086", token: "my-token", organization: "my-org", database: "my-database");
await client.WriteRecordsAsync(
records: new[] { "stat,unit=temperature value=24.5", "stat,unit=temperature value=25.5" },
headers: new Dictionary<string, string> { { "X-Tracing-Id", "123" } }
);