Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mtail is not considering timestamp parsed from the log #271

Closed
sandeepkonda opened this issue Sep 27, 2019 · 12 comments
Closed

mtail is not considering timestamp parsed from the log #271

sandeepkonda opened this issue Sep 27, 2019 · 12 comments

Comments

@sandeepkonda
Copy link

sandeepkonda commented Sep 27, 2019

Hi,

I have used strptime to parse the timestamp from log, but mtail is still using current system time as the time of the event instead of timestap from log file.

I have built docker image using Dockerfile availble in mtail repo.

Docker run command used,
docker run -it -p 3903:3903 -v /Users/san/progs/tomcat.mtail:/progs/tomcat.mtail -v /Users/san/logs:/logs mtail -logtostderr -progs /progs/tomcat.mtail -logs /logs/localhost_access_log.txt --emit_metric_timestamp

Below is the output of mtail --version
mtail version v3.0.0-rc33-51-g5b5a874 git revision 5b5a8747c571f4573e68e3a0d38b747860c6f887 go version go1.12.3 go arch amd64 go os linux

Content of mtail progam,

counter apache_http_requests_total by request_method, uri, request_status
counter apache_http_bytes_total by request_method, http_version, request_status

/^/ +
/[(?P\d{2}/\w{3}/\d{4}:\d{2}:\d{2}:\d{2} [+|-]\d{4})] / +
/(?P<client_hostname>[0-9A-Za-z.:-]+) / +
/(?P<server_hostname>[0-9A-Za-z.:-]+) / +
/(?P<remote_username>[0-9A-Za-z-\]+) / +
/- (?P\d{4}) / +
/(?P<request_method>[A-Z]+) (?P\S+) (?P<http_version>HTTP/[0-9.]+) / +
/(?P<request_status>\d{3}) / +
/(?P<response_size>\d+) / +
/(?P<response_time>\d+)/ +
/$/ {
strptime($timestamp, "02/Jan/2006:15:04:05 -0700")

apache_http_requests_total[$request_method][$uri][$request_status]++
$response_size > 0 {
apache_http_bytes_total[$request_method][$http_version][$request_status] += $response_size
}
}

Example Log line,
[17/Sep/2019:08:00:59 +0530] 10.222.45.26 10.222.45.26 CC\Administrator - 8444 GET /cc/rest/en_US/reports/execute/3D0EFF5E1000016D007217F60A6B2D16 HTTP/1.1 200 105401 10

Above program is correctly parsing the log line, below is the link to regex101 which verifies the regex,
https://regex101.com/r/2PmsWv/3

Output from /metrics endpoint
apache_http_requests_total{prog="tomcat.mtail",request_method="GET",request_status="200",uri="/cc/rest/en_US/reports/execute/3D0EFF5E1000016D007217F60A6B2D16"} 1 1568687459000

Here timestamp 1568687459000 is the time when mtail ran instead of 17/Sep/2019:08:00:59 +0530 from log.

@sandeepkonda sandeepkonda changed the title mtail not cosidering timestamp parsed from the log mtail is not considering timestamp parsed from the log Sep 27, 2019
@jaqx0r
Copy link
Contributor

jaqx0r commented Sep 27, 2019 via email

@jaqx0r
Copy link
Contributor

jaqx0r commented Sep 27, 2019 via email

@sandeepkonda
Copy link
Author

I have named it, I can see name timestamp in edit mode but somehow its getting removed by github on posting it. Same with port & uri, even they have been removed. Attached the program as docx document here.
tomcat program.docx

I don't see /tmp/mtail.INFO being created inside docker container or even on my machine.

@jaqx0r
Copy link
Contributor

jaqx0r commented Oct 1, 2019 via email

@sandeepkonda
Copy link
Author

I ran following commands to run mtail docker container on my Mac machine,

  1. git clone https://github.com/google/mtail.git
  2. cd mtail
  3. docker build -t mtail .
  4. docker run -it -p 3903:3903 -v /Users/sankonda/Downloads/progs/tomcat.mtail:/progs/tomcat.mtail -v /Users/sankonda/Downloads/logs:/logs mtail -logtostderr -progs /progs/tomcat.mtail -logs /logs/localhost_access_log.txt --emit_metric_timestamp

@jaqx0r
Copy link
Contributor

jaqx0r commented Oct 3, 2019 via email

@sandeepkonda
Copy link
Author

I tried following things but still no success,

  1. Mapped /tmp volume, still mtail.INFO not created,
    docker run -it -p 3903:3903 -v /Users/sankonda/Downloads/progs/tomcat.mtail:/progs/tomcat.mtail -v /Users/sankonda/Downloads/logs:/logs -v /Users/sankonda/Downloads/tmp:/tmp mtail -logtostderr -progs /progs/tomcat.mtail -logs /logs/localhost_access_log.txt --emit_metric_timestamp

  2. used -log_dir option, again mtail.INFO not created,
    docker run -it -p 3903:3903 -v /Users/sankonda/Downloads/progs/tomcat.mtail:/progs/tomcat.mtail -v /Users/sankonda/Downloads/logs:/logs -v /Users/sankonda/Downloads/info:/info mtail -logtostderr -progs /progs/tomcat.mtail -logs /logs/localhost_access_log.txt --emit_metric_timestamp -log_dir /info

@jaqx0r
Copy link
Contributor

jaqx0r commented Oct 3, 2019 via email

@sandeepkonda
Copy link
Author

I verified http://localhost:3903/progz?prog=tomcat.mtail
Last runtime error:
is empty

@Gilbert-T
Copy link

I verified http://localhost:3903/progz?prog=tomcat.mtail
Last runtime error:
is empty

Did you solved this problem?

@sandeepkonda
Copy link
Author

I verified http://localhost:3903/progz?prog=tomcat.mtail
Last runtime error:
is empty

Did you solved this problem?

No Gilbert, we had to move on to using telegraf due to few other considerations.

@jaqx0r jaqx0r closed this as completed Mar 20, 2021
@jaqx0r
Copy link
Contributor

jaqx0r commented Mar 20, 2021

there was insufficient information here to understand what the problem was

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants