Can I get Measurements or Fields from InfluxDatabase with C#? (InfluxDB ver2.0.8)

Hello, Please help me.
I have been searching ways about how to get Measurement list from InfluxDB(ver2.0.8) in C#, but I can’t find out. Of course, If I connect to Data Explorer in InfluxDB web page, I can see the list.
I want to make my “Data Explorer of InfluxDB” with C#, so I need Measurement list and Field list. I found some ways about it, but I was Python codes. Please let me know!!

I already know:
Influx DB’s => IP, Port, Token, Organization, Bucket Name
I want to know:
Measurement list and Field list

Main program language : C#

Thank you~!

Hi @Hwanny.Kim,

you can use schema.measurements() function and schema.measurementFieldKeys() in your Flux query.

The Flux query can be invoked by something like:

using System;
using System.Threading.Tasks;
using InfluxDB.Client;

namespace Examples
{
    public static class Query
    {
        public static async Task Main(string[] args)
        {
            const string org = "my-org";
            const string token = "my-token";
            const string bucket = "my-bucket";
            const string url = "http://localhost:8086";
            using var client = InfluxDBClientFactory.Create(url, token);

            var query = $"import \"influxdata/influxdb/schema\"\n" +
                        $"schema.measurements(bucket: \"{bucket}\")";

            var queryApi = client.GetQueryApi();

            //
            // QueryData
            //
            var tables = await queryApi.QueryAsync(query, org);
            tables.ForEach(table =>
            {
                table.Records.ForEach(record =>
                {
                    Console.WriteLine($"{record.GetTime()}: {record.GetValueByKey("_value")}");
                });
            });
        }
    }
}

Regards

Thank you~! It works well.
I’m much obliged to you for helping me.