That helped me some Michael.

I have made a complete regex for my ssl_request_log and i am able to use 
these fields.

counter apache_http_requests_total by request_method, http_version, 
response_code
counter apache_http_bytes_total by request_method, http_version, 
response_code
counter apache_http_ip_total by request_method, http_version, IP
counter apache_http_endpoint_total by request_method, http_version, endpoint

*/^(?P<IP>\d+\.\d+\.\d+\.\d+)\ +(?P<hostname>[0-9A-Za-z-\.]+)\ +-\ +-\ 
+\[(?P<timestamp>\d{2}\/\w{3}\/\d{4}:\d{2}:\d{2}:\d{2} \+\d{4})\]\ 
+(?P<tls_version>TLSv\d\.\d)\ +(?P<cipher>[0-9A-Za-z-]+)\ 
+\"(?P<request_method>[A-Z]+)\ +(?P<endpoint>[A-Za-z\/_\.]+)\ 
+(?P<http_version>HTTP\/\d\.\d)\"\ +(?P<response_code>\d{3})\ 
+(?P<response_size>[\d-]+)\ +(?P<time_to_serve>\d+)\ 
+\"(?P<url>[0-9A-Za-z-\.:?=\/_&+]+)\"\ 
+\"(?P<browser>[0-9A-Za-z-\.:?=\/_;\(\) ]+)\"\ +\"(?P<stat1>[\w-]+)\"\ 
+\"(?P<stat2>[\w-]+)\"/ {*

*  
apache_http_requests_total[$request_method][$http_version][$response_code]++*
*  $response_size > 0 {*
*      
apache_http_bytes_total[$request_method][$http_version][$response_code] += 
$response_size*
*      apache_http_ip_total[$request_method][$http_version][$IP]++*
*      
apache_http_endpoint_total[$request_method][$http_version][$endpoint]++*
*  }*
*}*

So that is working.

Now i'm left with the question how to most simply use a mtail prog to scan 
for text in different files with different setups.
I now have this:

*counter ERROR_in_log by log_file*
*counter WARN_in_log by log_file*
*counter API_Inc_in_log by log_file*
*counter total_hits_in_log by log_file*


*/(.*)/ {*
*  $1 =~ /ERROR/ {*
*    ERROR_in_log[getfilename()]++*
*  }*
*  $1 =~ /WARN/ {*
*    WARN_in_log[getfilename()]++*
*  }*
*  $1 =~ /Incoming API request from/ {*
*    API_Inc_in_log[getfilename()]++*
*  }*
*  total_hits_in_log[getfilename()]++*
*}*

But i think it can be better streamlined....
Also i suspect if a logline has ERROR and WARN in it the WARN is not 
counted.
So if i put in more elements some might be skipped.

Op donderdag 24 september 2020 om 13:52:43 UTC+2 schreef Michael Ströder:

> On 9/24/20 1:21 PM, Danny de Waard wrote:
> > Okay... i made a simple tes like this.
> > 
> > counter error_messages_in_log
> > counter warn_messages_in_log
> > counter total_messages_in_log
>
> Why not use labels for the log level?
>
> Here's what I'm doing in my Æ-DIR for counting messages per log level
> written by various Python software:
>
>
> https://gitlab.com/ae-dir/ansible-ae-dir-server/-/blob/master/templates/mtail/aedir_proc.mtail.j2
>
> Ciao, Michael.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/d9d08ed9-843c-4b4c-83a4-b6b7305706f4n%40googlegroups.com.

Reply via email to