Beispiel #1
0
//createTemplate creates the nagflux template.
func (connector *Connector) createTemplate() bool {
	mapping := fmt.Sprintf(NagfluxTemplate, connector.index, config.GetConfig().Elasticsearch.NumberOfShards, config.GetConfig().Elasticsearch.NumberOfReplicas)
	createIndex, _ := helper.SentReturnCodeIsOK(connector.httpClient, connector.connectionHost+"_template/"+connector.index, "PUT", mapping)
	if !createIndex {
		return false
	}
	return true
}
Beispiel #2
0
//TestTemplateExists test active if the template exists.
func (connector *Connector) TestTemplateExists() bool {
	result, body := helper.SentReturnCodeIsOK(connector.httpClient, connector.connectionHost+"_template", "GET", "")
	if result && strings.Contains(body, fmt.Sprintf(`"%s":`, connector.index)) {
		connector.templateExists = true
	} else {
		connector.templateExists = false
	}
	return connector.templateExists
}