Interface IInfluxDBClient
Inherited Members
Namespace: InfluxDB3.Client
Assembly: InfluxDB3.Client.dll
Syntax
public interface IInfluxDBClient : IDisposable
Methods
Query(string, QueryType?, string?, Dictionary<string, object>?, 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 |
---|---|---|
string | query | The SQL query string to execute. |
QueryType? | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
string | database | The database to be used for InfluxDB operations. |
Dictionary<string, 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. |
Dictionary<string, 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<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" } }
);
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The client is already disposed |
QueryBatches(string, QueryType?, string?, Dictionary<string, object>?, 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 |
---|---|---|
string | query | The SQL query string to execute. |
QueryType? | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
string | database | The database to be used for InfluxDB operations. |
Dictionary<string, 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. |
Dictionary<string, 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" } }
);
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The client is already disposed |
QueryPoints(string, QueryType?, string?, Dictionary<string, object>?, 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 |
---|---|---|
string | query | The SQL query string to execute. |
QueryType? | queryType | The type of query sent to InfluxDB. Default to 'SQL'. |
string | database | The database to be used for InfluxDB operations. |
Dictionary<string, 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. |
Dictionary<string, 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" } }
);
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The client is already disposed |
WritePointAsync(PointData, string?, WritePrecision?, 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 = default)
Parameters
Type | Name | Description |
---|---|---|
PointData | point | Specifies the Data point to write into InfluxDB. The point is considered as one batch unit. |
string | database | The database to be used for InfluxDB operations. |
WritePrecision? | precision | The to use for the timestamp in the write API call. |
Dictionary<string, 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>, string?, WritePrecision?, 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 = default)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<PointData> | points | Specifies the Data points to write into InfluxDB. The points is considered as one batch unit. |
string | database | The database to be used for InfluxDB operations. |
WritePrecision? | precision | The to use for the timestamp in the write API call. |
Dictionary<string, 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, string?, WritePrecision?, 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 = default)
Parameters
Type | Name | Description |
---|---|---|
string | record | Specifies the record in InfluxDB Line Protocol. The record is considered as one batch unit. |
string | database | The database to be used for InfluxDB operations. |
WritePrecision? | precision | The to use for the timestamp in the write API call. |
Dictionary<string, 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>, string?, WritePrecision?, 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 = default)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<string> | records | Specifies the records in InfluxDB Line Protocol. The records is considered as one batch unit. |
string | database | The database to be used for InfluxDB operations. |
WritePrecision? | precision | The to use for the timestamp in the write API call. |
Dictionary<string, 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" } }
);