Skip to content

Feature/195 log agent activity

Julien Andrieux requested to merge feature/195-log-agent-activity into develop

Closes #195 (closed)

Storing agent' activity

> select * from "activity-kDtJz8EqQ0C7KgOF6qwxfg";
name: activity-kDtJz8EqQ0C7KgOF6qwxfg
time                agent                  organization           type
----                -----                  ------------           ----
1522851745939681031 noLlUczuSJqkyIEynnCoow kDtJz8EqQ0C7KgOF6qwxfg /api.Pantomath/ListChannelTypes

Getting the activity

In the server' logs:

14:22:44.899 [WARN] authenticateAgent: Missing agent UUID (serve.go:69)
14:22:44.902 [DEBU] GetActivity: Retrieving activity for agent:9e82e551-ccee-489a-a4c8-81329e70a8a3 [organization:903b49cf-c12a-4340-bb2a-0385eaac317e] (tsdb.queryOptions{Tags: map[agent:noLlUczuSJqkyIEynnCoow], OrderBy: descending, Count: 1}) (activity.go:100)
14:22:44.903 [INFO] queryActivity: Fetching activity for noLlUczuSJqkyIEynnCoow (activity.go:120)
14:22:44.903 [DEBU] queryActivity: Query: SELECT * FROM "activity-kDtJz8EqQ0C7KgOF6qwxfg" WHERE agent='noLlUczuSJqkyIEynnCoow' ORDER BY time DESC LIMIT 1  (activity.go:121)
14:22:44.905 [INFO] queryActivity: Fetched 1 rows (activity.go:137)
$ curl -s -H "api-key:f90d9d23-b0cf-410a-b1cc-d0f8678f8b8b" -H "Content-Type: application/json" -XGET 'http://localhost:7576/v1/organizations/kDtJz8EqQ0C7KgOF6qwxfg/agents' | jq
{
  "agents": [
    {
      "name": "organizations/kDtJz8EqQ0C7KgOF6qwxfg/agents/noLlUczuSJqkyIEynnCoow",
      "display_name": "agent.pantomath.io",
      "last_activity": "2018-04-04T08:44:39.064211596Z"
    }
  ],
  "next_page_token": "Jgokb3JnYW5pemF0aW9ucy9rRHRKejhFcVEwQzdLZ09GNnF3eGZnAQ"
}
Edited by Julien Andrieux

Merge request reports