Hi folks: I poked around but couldn’t find the answer here.
I want to be able to construct a match filter that is based on the number of lines taht were just parsed. My goal is to skip when there is only one line.
My logs look something like this:
batch job running
batch job running
batch job running
batch job running
batch job running
batch job running
batch job running
WARNING Property: Unknown Property name. [11:3: overflow-wrap]
batch job running
batch job running
batch job running
WARNING Property: Unknown Property name. [11:3: overflow-wrap]
batch job running
08:08:20 Traceback (most recent call last):
File "/home/erp/erpnext/env/lib/python3.8/site-packages/rq/worker.py", line 1013, in perform_job
rv = job.perform()
File "/home/erp/erpnext/env/lib/python3.8/site-packages/rq/job.py", line 709, in perform
self._result = self._execute()
File "/home/erp/erpnext/env/lib/python3.8/site-packages/rq/job.py", line 732, in _execute
result = self.func(*self.args, **self.kwargs)
File "/home/erp/erpnext/apps/frappe/frappe/utils/background_jobs.py", line 164, in execute_job
frappe.db.commit()
File "/home/erp/erpnext/apps/frappe/frappe/database/database.py", line 908, in commit
self.sql("commit")
File "/home/erp/erpnext/apps/frappe/frappe/database/database.py", line 180, in sql
self._cursor.execute(query)
File "/home/erp/erpnext/env/lib/python3.8/site-packages/pymysql/cursors.py", line 148, in execute
result = self._query(query)
File "/home/erp/erpnext/env/lib/python3.8/site-packages/pymysql/cursors.py", line 310, in _query
conn.query(q)
File "/home/erp/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py", line 547, in query
self._execute_command(COMMAND.COM_QUERY, sql)
File "/home/erp/erpnext/env/lib/python3.8/site-packages/pymysql/connections.py", line 793, in _execute_command
raise err.InterfaceError(0, "")
pymysql.err.InterfaceError: (0, '')
batch job running
batch job running
batch job running
batch job running
Yea, there’s no timestamp (we didn’t write the app).
My goal of course is to NOT log the lines “batch j ob running” but do log the error, which frustratingly enough doesn’t have the word ‘error’, and the warning. I don’t know ahead of time exactly what the strings will consist of, so I don’t want to build include match blocks.
Is there a way to filter on # of lines? I thought maybe there was a lines parsed metric I could filter on?
For completeness my promtail setup is:
- job_name: worker_error_logs
static_configs:
- targets:
- localhost
labels:
job: worker
app: ourapp
__path__: /home/app/ourapp/logs/worker.error.log
pipeline_stages:
- multiline:
firstline: '^batch job running'
max_lines: 128
max_wait_time: 3s
Thank you,
== John ==