【发布时间】:2020-01-02 07:35:57
【问题描述】:
在我的 ElasticSearch 中,为 metricbeat 创建了一个带有日期后缀的新索引。即“metricbeat-7.1-2019.12.20”。现在我正在尝试从最新创建的索引中读取系统参数,但我不知道该怎么做。
var nodes = new Uri[]
{
new Uri(_options.Value.ElasticSearchUrl),
};
connectionPool = new StaticConnectionPool(nodes);
string indexName = "metricbeat*";
connectionSettings = new ConnectionSettings(connectionPool).DefaultIndex(indexName);
elasticClient = new ElasticClient(connectionSettings);
string[] systemFields = new string[]
{
"system.memory.*"
};
var elasticResponse = elasticClient.Search<object>(s => s
.DocValueFields(dvf => dvf.Fields(systemFields)));
elasticResponse 为我提供数据,但它在时间戳中显示较旧的日期。
请提出建议。
string[] systemFields = new string[]
{
"system.memory.actual.used.pct",
"system.cpu.total.norm.pct",
"system.load.5",
"docker.diskio.summary.bytes"
};
var elasticResponse = elasticClient.Search<object>(s => s
.DocValueFields(dvf => dvf.Fields(systemFields))
.Aggregations(ag => ag.Max("last_process_time", sa => sa
.Field("@timestamp")))
);
【问题讨论】:
-
给出准确的索引名称,不要像上面那样使用通配符。
标签: elasticsearch nest metricbeat