Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Integration for InfluxDB #464

Open
patrick-dmxc opened this issue Feb 10, 2025 · 5 comments
Open

Add Integration for InfluxDB #464

patrick-dmxc opened this issue Feb 10, 2025 · 5 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration

Comments

@patrick-dmxc
Copy link

Hi,
im using InfluxDB in my Project because it Stores a lott of Timestamp bassed Data.
To use Aspire i need a Propper InfluxDB integration

@aaronpowell aaronpowell added good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration labels Feb 10, 2025
@linnapuo
Copy link

Hello,
I have been learning .NET Aspire ecosystem for a while now. I think it's a powerful tool to create modern projects. The developer experience is excellent.

To deepen my knowledge I have been looking for ways to contribute. While I'm not familiar with InfluxDB more than spinning up the docker image and skimming the docs, would you say this is a good place to start?

I think I could get something going this week to get the conversation started.

@patrick-dmxc
Copy link
Author

Hi @linnapuo thanks,
this wold be nice, im yet not deep enougth in Aspire for do it my self

@linnapuo
Copy link

InfluxDB has version 3 in public alpha. Should we wait for a full release, or work with the stable version 2?

@patrick-dmxc
Copy link
Author

patrick-dmxc commented Feb 19, 2025

Version 2 should be good to start with

@linnapuo
Copy link

Work in progress https://github.com/linnapuo/CommunityToolkitAspire/tree/feat/influx
I got a basic client-server communication working now.

Do you have some use cases in mind, maybe some code to look at? It could help us decide what settings or parameters are needed.

Here's a quick rundown.

AppHost

  • A container with image influxdb:2.7.11-alpine
  • DOCKER_INFLUXDB_INIT_MODE=setup
  • DOCKER_INFLUXDB_INIT_USERNAME=username
  • DOCKER_INFLUXDB_INIT_PASSWORD=password
  • DOCKER_INFLUXDB_INIT_ORG=my-org
  • DOCKER_INFLUXDB_INIT_BUCKET=my-bucket
  • DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=[generated token]
var builder = DistributedApplication.CreateBuilder(args);

var influx = builder.AddInfluxDB("influxdb");

builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_InfluxDB_ApiService>("apiservice")
    .WithReference(influx)
    .WaitFor(influx);

builder.Build().Run();

Client

  • Using https://github.com/influxdata/influxdb-client-csharp
  • IInfluxDBClient is registered as a transient service
  • Read configuration from "Aspire:InfluxDB:Client"
  • Connection string is "http://{host}:{port}?token={token}" where token is the generated admin/operator token
using InfluxDB.Client;

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();

builder.AddInfluxDBClient("influxdb");

var app = builder.Build();

app.MapGet("/", async (IInfluxDBClient client) =>
{
    var success = await client.PingAsync();
    return Results.Text($"InfluxDB healthy: {success}");
});

app.MapDefaultEndpoints();
app.Run();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed integration A new .NET Aspire integration
Projects
None yet
Development

No branches or pull requests

3 participants