"error":   err,
					"esIndex": esIndex,
				}).Error(`Could not create an elasticsearch index`)

			}
		}

		// Create an Elasticsearch document. The document type will define the mapping used for the document.
		doc := make(map[string]interface{})
		var docID string
		docID = sensuhandler.EventName(sensuEvent.Client.Name, sensuEvent.Check.Name)
		doc["monitored_instance"] = sensuEvent.AcquireMonitoredInstance()
		doc["sensu_client"] = sensuEvent.Client.Name
		doc["incident_timestamp"] = time.Unix(sensuEvent.Check.Issued, 0).Format(time.RFC3339)
		doc["check_name"] = sensuhandler.CreateCheckName(sensuEvent.Check.Name)
		doc["check_state"] = sensuhandler.DefineStatus(sensuEvent.Check.Status)
		doc["sensuEnv"] = sensuhandler.DefineSensuEnv(sensuEnv.Sensu.Environment)
		doc["tags"] = sensuEvent.Check.Tags
		doc["instance_address"] = sensuEvent.Client.Address
		doc["check_state_duration"] = sensuhandler.DefineCheckStateDuration()

		// Add a document to the Elasticsearch index
		_, err = client.Index().
			Index(esIndex).
			Type(esType).
			Id(docID).
			BodyJson(doc).
			Do()
		if err != nil {
			syslogLog.WithFields(logrus.Fields{
				"check":   "sensupluginses",
Ejemplo n.º 2
0
					Value: sensuEvent.AcquireMonitoredInstance(),
					Short: true,
				},
				slack.AttachmentField{
					Title: "Sensu Client",
					Value: sensuEvent.Client.Name,
					Short: true,
				},
				slack.AttachmentField{
					Title: "Check Name",
					Value: sensuEvent.Check.Name,
					Short: true,
				},
				slack.AttachmentField{
					Title: "Check State",
					Value: sensuhandler.DefineStatus(sensuEvent.Check.Status),
					Short: true,
				},
				slack.AttachmentField{
					Title: "Event Time (UTC)",
					Value: time.Unix(sensuEvent.Check.Issued, 0).Format(time.RFC3339),
					Short: true,
				},
				slack.AttachmentField{
					Title: "Check State Duration",
					Value: strconv.Itoa(sensuhandler.DefineCheckStateDuration()),
					Short: true,
				},
				slack.AttachmentField{
					Title: "Current Threshold",
					Value: sensuEvent.AcquireThreshold(),