Giter Site home page Giter Site logo

Comments (5)

tstack avatar tstack commented on June 6, 2024 1

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.

tstack avatar tstack commented on June 6, 2024 1

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:

"annotations": {
"com.vmware.vmacore.backtrace": {
"description": "Convert a vmacore backtrace into human-readable text",
"condition": ":log_body LIKE '%[context]%[/context]%'",
"handler": "com.vmware.btresolver.py"
}
}

Window 2023-07-28 at 20 10 32

from lnav.

tstack avatar tstack commented on June 6, 2024

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.

ostrolucky avatar ostrolucky commented on June 6, 2024

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.

ostrolucky avatar ostrolucky commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.