Skip to main content
Question

How to get Event Logs

  • January 24, 2024
  • 4 replies
  • 274 views

Forum|alt.badge.img+1

Hi , how get Event Logs from REST / API? like we have from web interface 



 

 

4 replies

Forum|alt.badge.img+1
  • Steward *
  • January 24, 2024

give the host name or service name

select the dates and time 

check the critical, warning or whatever status required then apply period and export it as csv


Forum|alt.badge.img+1
  • Author
  • Steward *
  • January 24, 2024

Hello, I want to get events logs programmatically → API


lpinsivy
Centreonian
Forum|alt.badge.img+21
  • Centreonian
  • January 24, 2024

Hi @fky you can use Timeline endpoint to get event logs of a unique resource (host or service):

https://docs-api.centreon.com/api/centreon-web/23.10/#tag/Timeline

If you want to have the same functionality as “Event Logs” page, you must call xml.php as your browser call, for example:

curl 'https://<IP_CENTREON>/centreon/include/eventLogs/export/data.php?output=&oh=false&warning=true&unknown=true&critical=true&ok=true&unreachable=true&down=true&up=true&num=0&error=1&alert=true&notification=false&search_H=&search_S=&period=1209600&StartDate=01/24/2024&EndDate=01/24/2024&StartTime=00:00&EndTime=24:00&limit=30&id=HH_17,HH_21,HH_20,HH_18,HH_19,HH_85&export=1' \
-H 'Cookie: PHPSESSID=<PHPSESSID>' \
--compressed

 

 


Forum|alt.badge.img+1
  • Author
  • Steward *
  • January 25, 2024

Hello Laurent,

If I pass the following url https://my_centreon_server/centreon/include/eventLogs/export/data.php?output=&oh=false&warning=true&unknown=true&critical=true&ok=true&unreachable=true&down=true&up=true&num=0&error=1&alert=true&notification=false&search_H=&search_S=&period=&StartDate=01/24/2024&EndDate=01/25/2024&StartTime=00:00&EndTime=00:00&limit=30&id=&export=1, to my Internet browser I works


But if I try to do it from command line , it failed

Bad Session

Invoke-WebRequest -Uri "https://my_centreon_server/centreon/include/eventLogs/export/data.php?output=&oh=false&warning=true&unknown=true&critical=true&ok=true&unreachable=true&down=true&up=true&num=0&error=1&alert=true&notification=false&search_H=&search_S=&period=&StartDate=01/24/2024&EndDate=01/25/2024&StartTime=00:00&EndTime=00:00&limit=30&id=&export=1” 

StatusCode        : 200
StatusDescription : OK
Content           : Bad Session
RawContent        : HTTP/1.1 200 OK
                    Pragma: no-cache
                    X-Frame-Options: sameorigin
                    Keep-Alive: timeout=5, max=100
                    Connection: Keep-Alive
                    Transfer-Encoding: chunked
                    Cache-Control: no-store, no-cache, must-revalidate
                    ...
Forms             : {}
Headers           : {[Pragma, no-cache], [X-Frame-Options, sameorigin], [Keep-Alive, timeout=5, max=100], [Connection, Keep-Alive]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 11

Any idea?

Franck