2

I need history of "output" attribute for one check, but exploring Redis i understand that Sensu stores complete results of check only for last check execution? And history of status codes, but it is not important for me now.

I have come with solution to create handler for check, which will add check results to Redis with timestamp as a key. And later have a script which extracts data from Redis.

Is there any simpler way to do this?

Thanks for help :)

miki
  • 380
  • 6
  • 15

2 Answers2

2

Without using handlers, you could take a look at the output, return values, and get more information about the results, from the logs: /var/log/sensu/sensu-server.log. If you want to make something sophisticated, I think you need to use the API: https://sensuapp.org/docs/latest/api-results.

The API /results/:client/:check (GET) returns "output": "WARNING Found 0 matching processes\n",

Enrique Arriaga
  • 499
  • 2
  • 6
  • Thanks for the answer. :) I've checked it, it looks promising. Tomorrow i will explore it little bit more. – miki Feb 10 '16 at 03:01
  • In sensu-server.log there is no output of checks, but i have found it in sensu-client.log . Because in this test both client and server are on same computer, i can use it. Stupid question, but how can i query api for results (like in the link you provided)? I'm searching the internet, but no solutions found for now. – miki Feb 10 '16 at 15:22
  • And one more question :) Is it possible, using the API, to somehow be notified of every writting to Redis for specific check, so i can save it somewhere else? – miki Feb 10 '16 at 15:22
  • Ok, i understand how to use API now :) Just write to browser address and port (in my case localhost:4567/results ), and add /results ... – miki Feb 10 '16 at 15:33
1

Ok, i have understood everything i asked in a question, and i will give some explanations for future readers.

Sensu stores in Redis only last check results and history of exit codes for that check. By @Enrique Arriaga answer, there is log file in Sensu where history of ALL checks is written. It can be used for extracting data, but it is not intended for user log.

User has option of using Handler, which is triggered after every check (metric handler is triggered after every run, but other handler types are triggered after exit code changes value from previous execution!) run and provided with check results. It is up to user to decide what to do with results, should he add data to log file, store data to Redis, or something else.

miki
  • 380
  • 6
  • 15