# Time Series Store

## Description

Time-series providers register through `IFlexTimeSeriesStore`. Your application code stays provider-agnostic while the selected provider handles ingestion, querying, and retention.

## Infrastructure arrangement

When you add a time-series provider through **Flex Studio**, Flex generates the provider infrastructure and configuration:

1. Provider files under `Infrastructure/Providers/{YourApplication}.DataStoreProviders/TimeSeries/{Provider}/`
2. Default configuration under `Application/EndPoints/{YourApplication}.EndPoint.CommonConfigs/AppSettings/DataStores/TimeSeries/{Provider}.json`

Flex auto-wires generated Queries/Handlers/Plugins that use `IFlexTimeSeriesStore`—you only register the provider.

## Configuration in DI

Register only the provider time-series store you need.

```csharp
// Pick ONE provider.
services.AddFlexAzureDataExplorerTimeSeriesStore(configuration);
// services.AddFlexInfluxDBTimeSeriesStore(configuration);
// services.AddFlexTimescaleDBTimeSeriesStore(configuration);
```

## appsettings.json

Time-series configuration is read from `FlexBase:DataStores:TimeSeries:<Provider>`.

```json
{
  "FlexBase": {
    "DataStores": {
      "TimeSeries": {
        "InfluxDB": {
          "Url": "http://localhost:8086",
          "Token": "<store-in-secrets>",
          "Organization": "your-org",
          "Bucket": "your-bucket"
        }
      }
    }
  }
}
```

## Sample usage ({YourApplication})

```csharp
public class MetricReporter
{
	private readonly IFlexTimeSeriesStore _timeSeries;

	public MetricReporter(IFlexTimeSeriesStore timeSeries)
		=> _timeSeries = timeSeries;

	public Task RecordAsync(MetricPoint point)
		=> _timeSeries.WriteAsync<MetricPoint>(point);
}

public class MetricPoint
{
	public string SeriesId { get; set; }
	public DateTime Timestamp { get; set; }
}
```

## Provider pages

* Azure Data Explorer (Kusto): `time-series-store/azure-data-explorer.md`
* InfluxDB: `time-series-store/influx-db.md`
* TimescaleDB: `time-series-store/timescale-db.md`

## Provider considerations

* Keep secrets (tokens/credentials/connection strings) out of source control.
* Configure retention and batching in the provider section to match your telemetry volume.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flexbase.in/data-and-providers/data-stores/time-series-store.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
