timestamp not working

34 views
Skip to first unread message

Vasilis Primudriy

unread,
Jun 11, 2015, 1:03:45 PM6/11/15
to stash...@googlegroups.com
Hi guys,
I'm stuck :( 

I'm trying to add an event to an existing service ("generic-web-service") with a specific timestamp, but for some reason, my timestamp is ignored and a current date is always used (see bellow) when the new event is added.


data = urllib.urlencode({
    "timestamp": "Mon, 28 Jun 2010 22:18:06 GMT",
    "message": "Might be up",
    "status": "warning"
})

resp, content = client.request("http://localhost:8070/admin/api/v1/services/generic-web-service" + "/events", "POST", body=data)
print json.loads(content)

This produces the follwing:

{u'status': {u'description': u'The service is experiencing intermittent problems', u'level': u'NORMAL', u'url': u'http://localhost:8070/admin/api/v1/statuses/warning', u'image': u'http://localhost:8070/images/icons/fugue/exclamation.png', u'default': False, u'id': u'warning', u'name': u'Warning'}, u'url': u'http://localhost:8070/admin/api/v1/services/generic-web-service/events/ahJkZXZ-c3Rhc2hib2FyZC1ocmRyEgsSBUV2ZW50GICAgICAyKMLDA', u'timestamp': u'Thu, 11 Jun 2015 16:58:26 GMT', u'sid': u'ahJkZXZ-c3Rhc2hib2FyZC1ocmRyEgsSBUV2ZW50GICAgICAyKMLDA', u'message': u'Might be up', u'informational': False}


Could someone please help by pointing me in the right direction?

Thanks.

Anurag Sood

unread,
Jun 12, 2015, 9:37:56 AM6/12/15
to stash...@googlegroups.com
Hi there,

When you are using POST to post the event, it is going to pick up time stamp defined in your Event model.

Check your models.py. Go to the section where Event is defined.

You will find start element to have auto_now_add=True. This is the reason that whever any event is added, it will be UTC time stamp for the event.

 start = db.DateTimeProperty(required=True, auto_now_add=True)


BTW, why are you trying to add Event date manually with the specific timestamp. Objective of using API should be to push event to stashboard as and when they occur.

If this is an exceptional requirement and you need to do this once a while to correct your data, you can manually update start date from SDK console.

Regards,
Anurag

Vasilis Primudriy

unread,
Jun 15, 2015, 11:50:01 AM6/15/15
to stash...@googlegroups.com
Hi Anurag.
Thanks for your reply. The reason I'm interested in changing the timestamp is because I have the need to post events that occured in the past (as you said, exceptional requirement).  I found the start variable that you were talking about and now everything is working great. 

Thanks again.
V.
Reply all
Reply to author
Forward
0 new messages