User Guide
Overview
Target users: Security and infrastructure operators who want to store Logpresso query results in Redis, or reference and clean up Redis values from a query
The Redis Client app provides extension commands that read and write a Redis server directly from a query.
- Look up key values and list elements with a query
- Store a value in Redis or push it to a list for each row of a query result
- Delete keys from Redis based on a query result
Tasks
Scenario: Force-terminate sessions of a suspected account takeover
Goal: Detect accounts suspected of takeover from login logs, and delete the sessions of those accounts that an application keeps in Redis, which forces them to log out.
Prerequisites:
- The connect profile from the Install Guide must exist.
- The target application must keep its sessions in Redis with keys of the form
session:<session ID>. Change the key format to match your application.
Steps:
- In Analytics > Logs, detect accounts that logged in from multiple countries within a short time, and check their session IDs. The table and field names are examples, so replace them to match your environment.
table duration=10m app_auth_logs
| stats dc(src_country) as countries, values(session_id) as sessions by user
| search countries >= 2
- Look up one suspicious session in Redis to confirm that it is a real session.
my_redisis the name of the connect profile.
- Delete all sessions of the confirmed accounts.
table duration=10m app_auth_logs
| stats dc(src_country) as countries, values(session_id) as sessions by user
| search countries >= 2
| explode sessions
| eval session_key=concat("session:", sessions)
| redis-del-batch profile=my_redis key=session_key
Result:
Step 2 outputs the value stored in the session. An empty value means the session does not exist or has already expired.
| key | value |
|---|---|
| session:s1 | {"user":"alice","ip":"203.0.113.7"} |
Step 3 outputs one row per session, and a deleted value of 1 means the session was deleted. A value of 0 means the session was already gone. Deletion cannot be undone, and the user must log in again.