Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in message for bulletins metric #11

Open
vanducng opened this issue Mar 28, 2020 · 1 comment
Open

Add in message for bulletins metric #11

vanducng opened this issue Mar 28, 2020 · 1 comment

Comments

@vanducng
Copy link

vanducng commented Mar 28, 2020

I have no idea with golang, can you help or suggest any way to add the message comes with each bulletin even.
Thanks so much.

image

func (c *ProcessGroupsCollector) collect(ch chan<- prometheus.Metric, entity *client.ProcessGroupEntity) {
	bulletinCount := map[string]int{
		"INFO":    0,
		"WARNING": 0,
		"ERROR":   0,
	}
	for i := range entity.Bulletins {
		bulletinCount[entity.Bulletins[i].Bulletin.Level]++
	}

	for level, count := range bulletinCount {
		ch <- prometheus.MustNewConstMetric(
			c.bulletin5mCount,
			prometheus.GaugeValue,
			float64(count),
			entity.Component.Name,
			level,
			entity.Component.ID,

		)
	}
@vanducng
Copy link
Author

I think i will go with below code, manage to replicate what did for Level to Message. Because the message will disappear after 5 minutes on Nifi UI, it is important to log it (at least to my case) and send via AlertManager.

func (c *ProcessGroupsCollector) collect(ch chan<- prometheus.Metric, entity *client.ProcessGroupEntity) {
	
	errorCount := map[string]int{}
	for i := range entity.Bulletins {
		errorCount[entity.Bulletins[i].Bulletin.Message]++
	}

	for message, count := range errorCount {
		ch <- prometheus.MustNewConstMetric(
			c.bulletin5mCount,
			prometheus.GaugeValue,
			float64(count),
			entity.Component.Name,
			message,
			entity.Component.ID,
		)
	}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant