.NET SDK for writing data to GreptimeDB.
Warning This project is under heavy development. APIs may change without notice. Use at your own risk in production environments.
dotnet add package GreptimeDB.Ingesterusing GreptimeDB.Ingester.Client;
using GreptimeDB.Ingester.Table;
using GreptimeDB.Ingester.Types;
// Create client
var client = new GreptimeClient(new GreptimeClientOptions
{
Endpoint = "http://localhost:4001",
Database = "public"
});
// Build table
var table = new TableBuilder("cpu_metrics")
.AddTag("host", ColumnDataType.String)
.AddField("usage", ColumnDataType.Float64)
.AddTimestamp("ts", ColumnDataType.TimestampMillisecond)
.AddRow("server1", 0.85, DateTime.UtcNow)
.AddRow("server2", 0.72, DateTime.UtcNow)
.Build();
// Write
var affectedRows = await client.WriteAsync(table);
// Cleanup
await client.DisposeAsync();- Unary Write - Simple single-request writes via gRPC
- Streaming Write - High-throughput streaming via gRPC for multiple tables
- Bulk Write - Maximum throughput via Apache Arrow Flight
- Type coercion between .NET and GreptimeDB types
- Health check
- DI integration
For high-throughput scenarios with multiple tables:
await using var writer = client.CreateStreamIngestWriter();
// Write multiple tables in a single stream
await writer.WriteAsync(table1);
await writer.WriteAsync(table2);
await writer.WriteAsync(table3);
var affectedRows = await writer.CompleteAsync();For maximum throughput using Apache Arrow Flight protocol:
// Note: Tables must exist before using BulkWriter
await using var writer = client.CreateBulkWriter();
await writer.WriteAsync(table1);
await writer.WriteAsync(table2);
var affectedRows = await writer.CompleteAsync();Note: Unlike regular gRPC writes, Arrow Flight
DoPutdoes not auto-create tables. Ensure tables exist before usingBulkWriter.
services.AddGreptimeClient(options =>
{
options.Endpoint = "http://localhost:4001";
options.Database = "public";
});Apache License 2.0