VMware Modern Apps Community
corey_r
Community Manager
Community Manager
Jump to solution

Jenkins Deployment Notiofication

Hi,

How can we send deployment notification to Wavefront Charts?  is there an API Available?

Ex for New Relic-

Deployment notifications | New Relic Documentation

Reply
0 Kudos
1 Solution

Accepted Solutions
corey_r
Community Manager
Community Manager
Jump to solution

Hi Vikas,

That is a good question!

The event api has a flag "c" which should be set to true if you want to create instantaneous event. If you want to create a ongoing/non instantaneous event this flag should be set to false. And then you can pass start and end time to set the time window for the event.

You can easily pass variable values instead of constant epoch values through your script /command line.

Here is a quick example that creates the event for past 10 min duration from the command line

$ current_epochseconds=`date +%s`

$ ten_min_ago=`expr $current_epochseconds - 600`

$ curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-AUTH-TOKEN: XXXXXXXXXXXXX" -d "n=test_event&s=$ten_min_ago&e=$current_epochseconds&c=flase&h=pprdqbf*&l=info&t=code push" "https://intuit.wavefront.com/api/events"

Here I have simply created two variables to get the current epoch time and the epoch for the 10 mins before and then using these variables for s and e

s = $ten_min_ago

e = $current_epochsecond

You can use a similar logic in your POST calls aswell.  Hope this is helpful

Thanks,

Salil D

View solution in original post

Reply
0 Kudos
15 Replies
corey_r
Community Manager
Community Manager
Jump to solution

Hi Vikas,

In Wavefront you can create events ( ongoing and/or instantaneous ) to record such notifications or such environment specific occurrences.

Here are some articles from our knowledge base that should give you a good overview of how to create and use Events in Wavefront

Event Management Permission

Managing Event Displays from a dashboard

You can create these events programatically via the event apis as well - Here is the api documentation for the Events.

We also have built clients in python and ruby that you can use in your scripts to start using our api's to interact with Wavefront programatically. You can find these client on Wavefront's public repo on github

GitHub - wavefrontHQ/python-client: Python client for working with Wavefront

GitHub - wavefrontHQ/ruby-client: Ruby client for working with Wavefront

Hope this helps,

Thanks,

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Help me understand, How would i create an event published only to a specific Dashboard /Charts available within a Dashboard?

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

That is an excellent question Vikas!

In addition to ts( ) queries, Wavefront also has events( ) queries. events( ) queries allow you to specify a set of events that you'd like to have displayed on a given chart. There are several parameters you can use as filters, such as event name, type, severity, source, etc. Here is detail article on using events () queries and also the Time Series Language Guide provides every event filter that can be used with an events( ) query.

So after you have created the jenkins deployment events either via UI or automatically via the API as suggested in my earlier reply you can then use events( ) query to display it on your chart/s

For your case, I think using either a name or type filter with an events() query would work well.

If the event name will never change, then you could use the following events() query in a query field:

events(name="deployment_v1.2.3")

This would limit the event display results to only those events with the specified name. If the version will change over time, then you could use the same events() query, but replace the version info with a wildcard.

events(name="deployment_*")

You may want to change to a type filter though if the entire event name will continuously update over time. Rather than having to constantly update that information on each and every chart where it exists, you could simply add a particular type to the event you send into Wavefront. The type can be anything you'd like it to be, such as "jenkins-deployment", and can be applied in the events() query as well.

events(type="jenkins-deployment")

Using type as your filter would mean that you can change the event name as often as you'd like and it wouldn't stop those events from being displayed on the desired charts. Keep in mind that events will only be displayed on the x-axis of a chart when there is data present within the selected window. If there is NO DATA, then they won't appear.

Hope this is helpful.

Thanks,

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Thats Great. If there a way an event can be associated to a dashboard instead of associating with individual charts?

something like events(type="code push" and severity="informational" and dashboardname="Production_Dashboard")

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

When i try to post an event , i get "You are not authorized to perform this operation"

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-WF-CSRF-TOKEN: XXXXXXXXXX" -d "n=QBF%20Deployment&c=true&h=pprdqbf*&l=info&t=code%20push" "https://intuit.wavefront.com/api/events"

However from UI, i can create events fine

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Hi Vikas,

Ah, The swagger documentation allows you to experiment with APIs via the UI thoughto invoke an API via curl (or your code) you need a valid API token. To get one just go to Gear Icon → API Access and generate from there.

Screen+Shot+2016-05-18+at+4.55.07+PM.png

So if remove the X-WF-CSRF-TOKEN which is a toekn that is used  for the Swagger API Documents page  and replace it with your X-AUTH-TOKEN  then it would just work fine.

ex:

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-AUTH-TOKEN: <TOKEN>" -d "n=QBF%20Deployment&c=true&h=pprdqbf*&l=info&t=code%20push" "https://intuit.wavefront.com/api/events"

Hope this helps.

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Tried ! It does not work, same exception

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-AUTH-TOKEN: XXXXXXXXXXXXXX" -d "n=QBF%20Deployment&c=true&h=pprdqbf*&l=info&t=code%20push" "https://intuit.wavefront.com/api/events"

You are not authorized to perform this operation

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Oh.

Interesting, this usually means that the token does not have the right permission - "Event Management" permission in this case. I verified that your user "Event Management" permissions.

Also, I ran the above command with my token and same permissions as your profile to create a test event and it worked as expected.

Can you please re check if the you are using correct token.

Thanks,

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Absolutely, It was indeed the issue with my API Token. I fixed it and created an Event.

Associating the created event to the chart needs to be done. This is my successful response from cur

{"name":"QBF Deployment","startTime":1463628286255,"endTime":1463628286256,"annotations":{"severity":"info","type":"code push"},"hosts":["pprdqbf*"],"isUserEvent":true,"table":"intuit"}

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

The Post to create Event includes start date time & end date time  in epoch, is there a way to pass the event in the format required like put an event for 10 minutes

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Hi Vikas,

That is a good question!

The event api has a flag "c" which should be set to true if you want to create instantaneous event. If you want to create a ongoing/non instantaneous event this flag should be set to false. And then you can pass start and end time to set the time window for the event.

You can easily pass variable values instead of constant epoch values through your script /command line.

Here is a quick example that creates the event for past 10 min duration from the command line

$ current_epochseconds=`date +%s`

$ ten_min_ago=`expr $current_epochseconds - 600`

$ curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-AUTH-TOKEN: XXXXXXXXXXXXX" -d "n=test_event&s=$ten_min_ago&e=$current_epochseconds&c=flase&h=pprdqbf*&l=info&t=code push" "https://intuit.wavefront.com/api/events"

Here I have simply created two variables to get the current epoch time and the epoch for the 10 mins before and then using these variables for s and e

s = $ten_min_ago

e = $current_epochsecond

You can use a similar logic in your POST calls aswell.  Hope this is helpful

Thanks,

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Excellent,

The Event is created as expected. But The charts does not seem to show the event. I am using a Regex while posting the event, does wavefront API Support Regex?

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Accept: application/json" --header "X-AUTH-TOKEN: XXXXXX" -d "n=QBF%20Deployment&c=false&s=$ten_min_ago&e=$current_epochseconds&h=pprdqbfas8*&h=pprdqbfdb8*&h=pprdqbfws8*&l=info&t=code%20push" "https://intuit.wavefront.com/api/events"

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Great !

While creating the events however you need to send a full name of the host for which you want to associate the event to to the events api  and then in the chart .

The curl command that you have is accurate but the value for h= should be a fully qualified host name. You can provide multiple hosts by adding more than one h= parameters.

And then when you select "Display Source Events" on the chart the events the related events would be overlaid on chart of there are timeseries from that particular source on the chart.

The wildcards are supported on the query and should work on events queries ex: if you add additional query events(name="QBF Deployment" and source="pp*" ) would display all events with name QBF Deployment and have source that start with "pp"  -ex: https://intuit.wavefront.com/u/nRtZDVGKRf

If you are comfortable with writing python or ruby scripts we also have built clients in python and ruby that you can use in your scripts to start using our api's to interact with Wavefront programatically. You can find these client onWavefront's public repo on github

GitHub - wavefrontHQ/python-client: Python client for working with Wavefront

GitHub - wavefrontHQ/ruby-client: Ruby client for working with Wavefront

The python event api wrapper allows you to pass hosts as list of strings so that should make it easier for you to pass multiple hosts . I will write a script to create events using the python client and send it to you shortly.

Hope this helps,

Salil D

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

Thats a Bummer, Typically Large enterprise will have numerous hosts 50+ and dynamic in nature. Can we have a Feature request to support wildcard ?

Reply
0 Kudos
corey_r
Community Manager
Community Manager
Jump to solution

You got it ! We identify this as a valid feature to be added to the event api and I will file a feature request for this one with our product team.

Thanks,

Salil D

Reply
0 Kudos