Home > Blockchain >  Is there a way to list all Kibana dashboards via Nest in c#?
Is there a way to list all Kibana dashboards via Nest in c#?

Time:08-19

I am able to get a list of dashboards using a simple Get request in something like Postman:

http://localhost:9200/.kibana/_search?q=type:dashboard&size=20

However I need to get the list using the Nest client in C# and I have no idea how to form that sort of search request with the ElasticClient DSL. For more "traditional" searches I would use something like:

var settings = new ConnectionSettings(new Uri("http://localhost:9200/"))
    .DefaultMappingFor<ElasticCustomerDTO>(i => i
    .IndexName("customer")
    .IdProperty(p => p.Identifier)
);

var client = new ElasticClient(settings);

ISearchResponse<ElasticCustomerDTO> searchResponse = client.Search<ElasticCustomerDTO>(s => s
    .Query(q => q
        .SimpleQueryString(f => f
            .Query(filter.Name)
        )
    )
);

I'm struggling to create anything like the dashboard search query in that form (at least anything that returns results). Any help would be greatly appreciated.

CodePudding user response:

You can use below NEST query to get Kibana dashboards

var searchResponse = await client.SearchAsync<Dictionary<string, object>>(s => s
    .Index(".kibana")
    .QueryOnQueryString("type:dashboard")
    .Size(20));

foreach (var document in searchResponse.Documents)
{
    Console.WriteLine(((Dictionary<string, object>)document["dashboard"])["title"]);
}

I'm using Dictionary<string, object> as returned type as I don't think there is any type in NEST representing Kibana DTOs.

  • Related