Comments (5)
The shell_exec()
SQL function was recently added and can be used to execute a command. So, you can extract the user ID using one of the SQL JSON functions, like so:
;SELECT jget(context, '/upstream_session/user_id') AS userId FROM monologjson WHERE log_line = log_msg_line()
then do
;SELECT ... WHERE id=$userId
to retrieve corresponding entry from database
Is this an external database that you would be talking to? For example, with PostgreSQL, I think something like the following might work... but, I haven't tried it out for real:
;SELECT shell_exec(
'psql -v "userId=$userId"',
'SELECT ... WHERE id=:userId',
json_object('env', json_object('userId', $userId)))
from lnav.
Another new feature you might be interested in for this is the :annotate
command, which will run a script and then insert the output into the log view. The following annotation configuration will convert an encoded backtrace in a log file and insert something human-readable:
Lines 17 to 23 in c0e3931
![Window 2023-07-28 at 20 10 32](https://private-user-images.githubusercontent.com/107532/295033487-f4e94395-f22b-40cd-b0a7-912d7bf0d1b0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5NDkzODQsIm5iZiI6MTcyMTk0OTA4NCwicGF0aCI6Ii8xMDc1MzIvMjk1MDMzNDg3LWY0ZTk0Mzk1LWYyMmItNDBjZC1iMGE3LTkxMmQ3YmYwZDFiMC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzI1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyNVQyMzExMjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04NjNjOTY5MWYzZmMxM2UwNjhjM2M3YTZhODAyOTYwMzZkYWM4NzNlNGIyNTIyZWI4MGE0MGM2ZWVjNjg4YmU2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.GxdCkSuOtaCRE9KTX39AFmy7DHW2psVXLmvy4yGMvl8)
from lnav.
The :sh
command is intended to be used to asynchronously run a command where you want the output to be displayed in the log or text view. For example, using a command to get logs from a service would be a good use for :sh
. The --name
is used to name the output in the log/text view.
from lnav.
Hmm is there a synchronous command I can use to preprocess things for following steps in a script? My intention here is to use jq
with $log_raw_text
to extract ID from a message and then do ;SELECT ... WHERE id=$userId
to retrieve corresponding entry from database
from lnav.
Oh yeah this is all I need for my use case. Works great for my use case. Makes things fly unlike :sh as well, because of #1222
from lnav.
Related Issues (20)
- Pretty print regression for json logs HOT 4
- stdin and adb logcat -v time issues HOT 4
- 0.12.2 "top" mode navigation is broken HOT 1
- Custom theme location does not seem to work? HOT 4
- Enable native Caddy JSON log file format HOT 2
- Can it be built without Rust, disabling related module? HOT 2
- Cursor mode selection does not select expected lines HOT 1
- Feature request: hide/show "discovered fields"
- Customizable hidden fields separate so you can replace vertical ellipsis
- support for multiple JSON line-formats and switching between them HOT 1
- Add time filters to the Filters configuration panel
- Timezone ignored if miliseconds is absent HOT 3
- highlight log content using data parser
- A line with three quotes crashes lnav HOT 1
- Globbing (* wildcard) stop working on macos in remote HOT 1
- With enable-word-wrap found matches are below the fold
- env_logger format is not detected HOT 2
- Esc key doesn't abort HOT 2
- Crash with a specific regex pattern
- Crash when regex without body is used HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lnav.