如何在单个 API 调用中使用不同指标检查 elasticsearch 健康状况?
How to check elasticksearch health with different metrics in single API call?
我需要阅读以下 elasticksearch 指标
- 版本
- 正常运行时间
- 没有。职位
- 整体健康
- 没有。节点数
- 磁盘可用百分比
- JVM 堆大小
- 没有。指数
- 主要碎片
- 副本碎片
在 ASP.Net MVC 应用程序中。我的问题 :-
是否可以在 elasticsearch 中通过一次 API 调用来读取上述所有指标?
我写了下面的方法
private static string CheckESHealth()
{
string esurl = "http://localhost:9200/_cluster/health";
HttpClient httpClient = new HttpClient();
string strReturnVal = string.Empty;
try
{
var response = httpClient.GetAsync(new Uri(esurl)).Result;
if (response.IsSuccessStatusCode)
{
var esdata = response.Content.ReadAsStringAsync().Result;
if (!string.IsNullOrEmpty(esdata))
{
JObject jobject = JObject.Parse(esdata);
//as a example i have taken only status.. but i need all paramters mention above
strReturnVal = jobject["status"].ToString();
}
}
else
{
strReturnVal = "Errored : Received status code : " + response.StatusCode;
}
}
catch (Exception ex)
{
strReturnVal = "Errored : " + ex.Message;
}
return strReturnVal;
}
在上面的示例中,我使用的是:- GET _cluster/health 命令,它给出以下结果
enter image description here
但我试图在一次 API 调用中读取上述所有指标
我需要阅读以下 elasticksearch 指标
- 版本
- 正常运行时间
- 没有。职位
- 整体健康
- 没有。节点数
- 磁盘可用百分比
- JVM 堆大小
- 没有。指数
- 主要碎片
- 副本碎片
在 ASP.Net MVC 应用程序中。我的问题 :- 是否可以在 elasticsearch 中通过一次 API 调用来读取上述所有指标?
我写了下面的方法
private static string CheckESHealth()
{
string esurl = "http://localhost:9200/_cluster/health";
HttpClient httpClient = new HttpClient();
string strReturnVal = string.Empty;
try
{
var response = httpClient.GetAsync(new Uri(esurl)).Result;
if (response.IsSuccessStatusCode)
{
var esdata = response.Content.ReadAsStringAsync().Result;
if (!string.IsNullOrEmpty(esdata))
{
JObject jobject = JObject.Parse(esdata);
//as a example i have taken only status.. but i need all paramters mention above
strReturnVal = jobject["status"].ToString();
}
}
else
{
strReturnVal = "Errored : Received status code : " + response.StatusCode;
}
}
catch (Exception ex)
{
strReturnVal = "Errored : " + ex.Message;
}
return strReturnVal;
}
在上面的示例中,我使用的是:- GET _cluster/health 命令,它给出以下结果
enter image description here
但我试图在一次 API 调用中读取上述所有指标