TAF.Kibana.SDK 1.1.0

dotnet add package TAF.Kibana.SDK --version 1.1.0
                    
NuGet\Install-Package TAF.Kibana.SDK -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TAF.Kibana.SDK" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TAF.Kibana.SDK" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="TAF.Kibana.SDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TAF.Kibana.SDK --version 1.1.0
                    
#r "nuget: TAF.Kibana.SDK, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TAF.Kibana.SDK@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TAF.Kibana.SDK&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TAF.Kibana.SDK&version=1.1.0
                    
Install as a Cake Tool

TAF Kibana SDK

Official .NET SDK for TAF Kibana logging and analytics platform. Provides a fluent API for log management, searching, metrics, and real-time monitoring.

Installation

dotnet add package TAF.Kibana.SDK

Quick Start

Configuration

Add to your appsettings.json:

{
  "KibanaClient": {
    "BaseUrl": "https://your-kibana-instance.com/api",
    "ApiKey": "your-api-key",
    "TimeoutSeconds": 30,
    "MaxRetryAttempts": 3,
    "BulkBatchSize": 1000
  }
}

Dependency Injection

using TAF.Kibana.SDK.Extensions;

// In Program.cs or Startup.cs
services.AddTafKibanaClient(Configuration);

// Or with inline configuration
services.AddTafKibanaClient(options =>
{
    options.BaseUrl = "https://your-kibana-instance.com/api";
    options.ApiKey = "your-api-key";
});

Usage Examples

Basic Usage

public class LoggingService
{
    private readonly ITafKibanaClient _kibanaClient;

    public LoggingService(ITafKibanaClient kibanaClient)
    {
        _kibanaClient = kibanaClient;
    }

    public async Task LogEventAsync()
    {
        // Write a log entry
        await _kibanaClient.Logs.WriteAsync(new LogEntry
        {
            Level = "Information",
            Message = "User logged in",
            TenantId = tenantId,
            ApplicationId = appId
        });
    }
}

Fluent Search API

// Search for error logs in the last 24 hours
var results = await _kibanaClient.Query()
    .ForTenant(tenantId)
    .InLastHours(24)
    .WithLogLevel("Error", "Critical")
    .ContainingText("database connection")
    .OrderBy(x => x.Timestamp, SortDirection.Descending)
    .Take(100)
    .ExecuteAsync<LogEntry>();

// Stream large result sets
await foreach (var log in _kibanaClient.Query()
    .ForTenant(tenantId)
    .InDateRange(startDate, endDate)
    .StreamAsync<LogEntry>())
{
    ProcessLog(log);
}

Aggregations and Analytics

// Get log statistics with aggregations
var stats = await _kibanaClient.Query()
    .ForTenant(tenantId)
    .InLastDays(7)
    .WithAggregation(agg => agg
        .Terms("by_level", "level", size: 10)
        .DateHistogram("over_time", "timestamp", "1h")
        .Average("avg_response", "responseTime"))
    .ExecuteAsync<LogEntry>();

// Get metrics
var metrics = await _kibanaClient.Metrics.GetTimeSeriesAsync(
    metric: "response_time",
    from: DateTime.UtcNow.AddDays(-7),
    to: DateTime.UtcNow,
    interval: "1h");

Bulk Operations

// Bulk indexing with fluent API
var result = await _kibanaClient.Bulk()
    .IndexMany(logEntries)
    .WithBatchSize(500)
    .ContinueOnError(true)
    .WithRefresh(RefreshPolicy.WaitFor)
    .ExecuteAsync();

Console.WriteLine($"Indexed {result.SuccessfulOperations} of {result.TotalOperations} documents");

Real-time Monitoring

// Subscribe to real-time log stream
var subscription = await _kibanaClient.Realtime.SubscribeToLogsAsync(
    filter: query => query
        .ForTenant(tenantId)
        .WithLogLevel("Error"),
    onEvent: logEvent =>
    {
        Console.WriteLine($"New error: {logEvent.Message}");
    });

// Tail logs
await foreach (var log in _kibanaClient.Realtime.TailLogsAsync(
    filter: q => q.ForTenant(tenantId),
    initialLines: 100))
{
    Console.WriteLine($"[{log.Timestamp}] {log.Level}: {log.Message}");
}

Alert Management

// Create alert rule
var rule = await _kibanaClient.Alerts.CreateRuleAsync(new AlertRuleDefinition
{
    Name = "High Error Rate",
    Description = "Alert when error rate exceeds threshold",
    TenantId = tenantId,
    Severity = AlertSeverity.High,
    CheckInterval = TimeSpan.FromMinutes(5),
    Condition = new AlertCondition
    {
        Type = AlertConditionType.Query,
        Query = q => q.WithLogLevel("Error"),
        Operator = ComparisonOperator.GreaterThan,
        Threshold = 100,
        TimeWindow = TimeSpan.FromMinutes(5)
    },
    NotificationChannels = new[] { "email", "slack" }
});

// Get alert history
var alerts = await _kibanaClient.Alerts.GetAlertHistoryAsync(
    ruleId: rule.Id,
    from: DateTime.UtcNow.AddDays(-7));

Advanced Queries

// Complex field queries with expressions
var results = await _kibanaClient.Query()
    .ForTenant(tenantId)
    .Where<LogEntry>(x => x.Level == "Error" && x.ResponseTime > 1000)
    .WhereField("environment", SearchOperator.In, new[] { "production", "staging" })
    .WhereField("statusCode", SearchOperator.Between, new { from = 400, to = 599 })
    .WithHighlighting("message", "stackTrace")
    .WithCaching(TimeSpan.FromMinutes(5))
    .ExecuteAsync<LogEntry>();

// Export search results
var export = await _kibanaClient.Search.ExportAsync(
    request: queryBuilder.Build(),
    format: ExportFormat.Csv);

File.WriteAllBytes("logs.csv", export.Data);

Features

  • Fluent API: Intuitive query building with IntelliSense support
  • Resilience: Built-in retry policies and circuit breaker patterns
  • Streaming: IAsyncEnumerable support for processing large datasets
  • Real-time: WebSocket-based real-time log streaming and monitoring
  • Bulk Operations: Efficient bulk indexing with progress tracking
  • Caching: Query result caching for improved performance
  • Type Safety: Strongly-typed API with generic support
  • Compression: Automatic request/response compression
  • Health Checks: Built-in health check support

Configuration Options

Option Description Default
BaseUrl Kibana API base URL https://localhost:44356/
ApiKey API key for authentication -
TimeoutSeconds Request timeout in seconds 30
MaxRetryAttempts Maximum retry attempts 3
RetryDelayMilliseconds Delay between retries 1000
EnableLogging Enable debug logging false
BulkBatchSize Batch size for bulk operations 1000
EnableCompression Enable request compression true
CircuitBreakerThreshold Circuit breaker threshold 5
CircuitBreakerTimeoutSeconds Circuit breaker timeout 60

Advanced Configuration

Custom HTTP Client

services.AddTafKibanaClientWithCustomHttp(
    options => options.BaseUrl = "https://api.example.com",
    httpBuilder => httpBuilder
        .AddHttpMessageHandler<CustomAuthHandler>()
        .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
        {
            Proxy = new WebProxy("http://proxy:8080")
        }));

With Health Checks

services.AddTafKibanaClientWithHealthChecks(Configuration);

// In health check endpoint
app.MapHealthChecks("/health", new HealthCheckOptions
{
    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});

License

MIT

Support

For issues and feature requests, please contact the TechAppForce development team.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 71 9/18/2025
1.0.0 109 9/5/2025