ustream / openduty

An open source Alerting and incident escalation tool
MIT License
788 stars 188 forks source link

cant create event #75

Open gabrielfsousa opened 7 years ago

gabrielfsousa commented 7 years ago

doing

curl -H "Content-type: application/json" -X POST -d '{"service_key":"MY_OPENDUTY_SERVICE_KEY","event_type":"trigger","description":"test","incident_key":"1234567"}' http://172.16.9.141:8000/api/create_event

get

{}

krutaw commented 7 years ago

You're missing the authorization token. Here's an example of my curl command that I use in my DEV environment:

curl --insecure -H "Content-type: application/json" -H "Authorization: token thisismysecret" -X POST -d '{"service_key":"b893c504c51c26c720056ed94ec53049b9b9d0a4","event_type":"trigger","description":"test","incident_key":"1234567","details":"Details here"}' http://192.168.0.92:9080/api/create_event

Note, the service_key is the API Key from the service that I want to send the alert to in OpenDuty. I only mention that in case you hadn't replaced your service key with the text you included. Also, the token "thisismysecret" is the secret token defined within the settings.py.

gabrielfsousa commented 7 years ago

found out yesterday, reading your case :) thanks a lot

can we create a service using api ?

deathowl commented 7 years ago

Not yet, but that feature will come eventually. Check this for continously added features: github.com/openduty/openduty

hanynowsky commented 7 years ago

We are facing the same problem here:

curl --insecure -H "Content-type: application/json" -H "Authorization: token mySettingsSecretKey" -X POST -d '{"service_key":" 5b10505a55a41b6fd2664579d5521b6adad8689d","event_type":"trigger","description":"test","incident_key":"1244567","details":"Details here"}' http://127.0.0.1:8000/api/create_event
{}

" Log: [19/Sep/2017 15:20:48] "POST /api/create_event HTTP/1.1" 403 2

Any hint on what might be wrong. Everything is setup. Service key, Sekret key, users, service... etc

kjetilmjos commented 7 years ago

Have you created an escalation policy? I got the same problem when there was no escalation policy connected to the service

kjetilmjos commented 7 years ago

and also "Authorization: password_from_settings.py"

hanynowsky commented 7 years ago

Everything is setup correctly. Escalation policy is assigned to the service. But no luck. I am clueless. The Authorization is the password from settings.py. Yes.

kjetilmjos commented 7 years ago

You have used the API key created in the service as service_key ?

hanynowsky commented 7 years ago

Sure.

hanynowsky commented 7 years ago

http://hanine.magic.fr/public/openduty.png

kjetilmjos commented 7 years ago

Hmm. This is the curl I'm using and it works.

curl --insecure -H "Content-type: application/json" -H "Authorization: <<secret<<" -X POST -d '{"service_key":"<<apikey<<","event_type":"trigger","description":"test","incident_key":"123425","details":"Details here"}' http://172.16.200.160:8000/api/create_event

hanynowsky commented 7 years ago

Ok I found the cause. Shame on me :( It was a typo mistake in the service key. Look at my earlier command: curl --insecure -H "Content-type: application/json" -H "Authorization: token mySettingsSecretKey" -X POST -d '{"service_key":" 5b10505a55a41b6fd2664579d5521b6adad8689d","event_type":"trigger","description":"test","incident_key":"1244567","details":"Details here"}' http://127.0.0.1:8000/api/create_event

Thanks @kjetilmjos

kjetilmjos commented 7 years ago

That's good news! I'm having some problems with notifications. Think it has something with the celery task queue to do. Would be interesting to hear if you encounter the same problem. https://github.com/ustream/openduty/issues/90

hanynowsky commented 7 years ago

The Twilio Notification works fine for me. I receive SMS. The email notification has an issue. It does not work. The task is executed but after 254 seconds, reports an error. I am going to check shortly again what error it reports.

kjetilmjos commented 7 years ago

So you didn't have to do any code changes to the notification part? What OS are you running on? This is what I had to do to get email working: https://github.com/ustream/openduty/issues/49