Class WriteOptions
The WriteOptions class holds the configuration for writing data to InfluxDB.
You can configure following options:
- Precision: The default precision to use for the timestamp of points if no precision is specified in the write API call.
- GzipThreshold: The threshold in bytes for gzipping the body. The default value is 1000.
- TagOrder: Preferred tag order for line protocol serialization.
- NoSync: Bool value whether to skip waiting for WAL persistence on write. The default value is false.
- AcceptPartial: Allow partial writes on the V3 API endpoint. The default value is true.
- UseV2Api: Route writes to the V2 API endpoint (/api/v2/write). The default value is true.
If you want create client with custom options, you can use the following code:
using var client = new InfluxDBClient(new ClientConfig
{
Host = "https://us-east-1-1.aws.cloud2.influxdata.com",
Token = "my-token",
Organization = "my-org",
Database = "my-database",
WriteOptions = new WriteOptions
{
Precision = WritePrecision.S,
GzipThreshold = 4096,
NoSync = false
}
});
Implements
Inherited Members
Namespace: InfluxDB3.Client.Config
Assembly: InfluxDB3.Client.dll
Syntax
public class WriteOptions : ICloneable
Properties
AcceptPartial
Controls partial-write behavior on the V3 API endpoint. true (default): allow partial writes (server default behavior) false: reject the full batch when any line fails. This option is ignored for writes sent to the V2 API endpoint (UseV2Api=true).
Declaration
public bool AcceptPartial { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
DefaultTags
Tags added to each point during writing. If a point already has a tag with the same key, it is left unchanged.
var _client = new InfluxDBClient(new InfluxDBClientConfigs
{
HostUrl = "some-url",
Organization = "org",
Database = "database",
DefaultTags = new Dictionary <string, string ()
{
{ "rack", "main" },
}
});
// Writes with rack=main tag
await _client.WritePointAsync(PointData
.Measurement("cpu")
.SetField("field", 1)
);</code></pre></example>
Declaration
public Dictionary<string, string>? DefaultTags { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, string> |
GzipThreshold
The threshold in bytes for gzipping the body.
Declaration
public int GzipThreshold { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
NoSync
Instructs the server whether to wait with the response until WAL persistence completes. NoSync=true means faster write but without the confirmation that the data was persisted.
Note: This option is supported by InfluxDB 3 Core and Enterprise servers only. For other InfluxDB 3 server types (InfluxDB Clustered, InfluxDB Cloud Dedicated/Serverless) the write operation will fail with an error.
Default value: false.
Declaration
public bool NoSync { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Precision
The default precision to use for the timestamp of points if no precision is specified in the write API call.
Declaration
public WritePrecision? Precision { get; set; }
Property Value
| Type | Description |
|---|---|
| WritePrecision? |
TagOrder
Preferred order for tag keys when serializing points to line protocol. Tags listed here are emitted first (in the provided order), then any remaining tags are emitted in lexicographical order.
Declaration
public string[]? TagOrder { get; set; }
Property Value
| Type | Description |
|---|---|
| string[] |
UseV2Api
Routes writes to the V2 API endpoint (/api/v2/write). Default value: true.
Declaration
public bool UseV2Api { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Clone()
Creates a new object that is a copy of the current instance.
Declaration
public object Clone()
Returns
| Type | Description |
|---|---|
| object | A new object that is a copy of this instance. |