A call to myEvent.Entity.LastSeen returns a valid unix timestamp.
A call to myEvent.Entity.LastSeen returns 0.
One solution might be to:
LastSeen value along to the agent in the CheckRequest.LastSeen value when the event is produced.etcdctl get "/sensu.io/events/default/default/oh-deer/check-buck"last_seen value to be 0.An attempt was made to display the value in the Web UI.
Irrelevant.
Is this actually a bug? What should the value be if the event has never been seen? I think 0 would be a reasonable value in that case.
The entity, if it exists, should always have a last_seen timestamp. The behavior here should be similar to keepalive events, which do have a last_seen timestamp. I'm not sure what proxy entities should have for last_seen, I think there a zero value may make sense. Here's what event entities look like for keepalive, check, and proxy check events:
# Keepalive event entity
{
"timestamp": 1525287323,
"entity": {
"class": "agent",
"deregister": false,
"deregistration": {},
"environment": "default",
"id": "defiant.i.pdx.axcella.net",
"keepalive_timeout": 120,
"last_seen": 1525287323,
"organization": "default",
"redact": [
"password",
"passwd",
"pass",
"api_key",
"api_token",
"access_key",
"secret_key",
"private_key",
"secret"
],
"subscriptions": [
"test",
"entity:defiant.i.pdx.axcella.net"
],
"system": {
"hostname": "defiant.i.pdx.axcella.net",
"os": "darwin",
"platform": "darwin",
"platform_version": "10.13.4",
"network": {
"interfaces": [
{
"name": "en10",
"mac": "9c:eb:e8:56:18:8c",
"addresses": [
"fe80::872:3c65:d5b2:cb5/64",
"10.0.80.155/24"
]
}
]
},
"arch": "amd64"
},
"user": "agent"
}
# Check event entity
{
"timestamp": 1525287302,
"entity": {
"class": "agent",
"deregister": false,
"deregistration": {},
"environment": "default",
"id": "defiant.i.pdx.axcella.net",
"keepalive_timeout": 120,
"organization": "default",
"redact": [
"password",
"passwd",
"pass",
"api_key",
"api_token",
"access_key",
"secret_key",
"private_key",
"secret"
],
"subscriptions": [
"test",
"entity:defiant.i.pdx.axcella.net"
],
"system": {
"hostname": "defiant.i.pdx.axcella.net",
"os": "darwin",
"platform": "darwin",
"platform_version": "10.13.4",
"network": {
"interfaces": [
{
"name": "en10",
"mac": "9c:eb:e8:56:18:8c",
"addresses": [
"fe80::872:3c65:d5b2:cb5/64",
"10.0.80.155/24"
]
}
]
},
"arch": "amd64"
},
"user": "agent"
}
# Proxy event entity
{
"timestamp": 1525287213,
"entity": {
"class": "proxy",
"deregister": false,
"deregistration": {},
"environment": "default",
"id": "example.com",
"keepalive_timeout": 0,
"organization": "default",
"subscriptions": [
"entity:example.com",
"entity:example.com"
],
"system": {
"network": {
"interfaces": null
}
}
},
last_seen doesn't appear in the check event entity json. It should probably look like the keepalive entity does.
@mercul3s oh I totally missed that this was about _entities_ and not _events_. That makes much more sense to me now. Thank you for clarifying.
I've done the quick fix of adding the last_seen time at the agent when the event is created, and opened #1434 to figure out a longer term fix for the entity time source of truth.
Most helpful comment
I've done the quick fix of adding the
last_seentime at the agent when the event is created, and opened #1434 to figure out a longer term fix for the entity time source of truth.