Splunk Search

Search log for alert

dangtran
Explorer

Have good day for Everybody
Pls help me to search exactly the content.
My input log is:
status system replication site "1": ERROR
status system replication site "3": ACTIVE
overall system replication status: ERROR.
My search and will add the alert:
index="...." host="..." status system replication site "1": ACTIVE | head 1
the result is:
status system replication site "1": ERROR
status system replication site "3": ACTIVE
overall system replication status: ERROR.
But i couldn't know: site "1" ACTIVE or ERROR.
Pls help me define the searching.
Thank

Tags (1)
0 Karma
1 Solution

dangtran
Explorer

Hi Giuseppe,
The full one log have 32 line. i only copy the 3 line. This is not the log. Only i export the command line to the log file and send his file to the splunk. The log content is:
| SYSTEMDB | p-crm-db01 | 30601 | nameserver | 1 | 2 | CRM01 | p-crm-db02 | 30601 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| QP2 | p-crm-db01 | 30652 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30652 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| RP2 | p-crm-db01 | 30640 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30640 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| JP2 | p-crm-db01 | 30646 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30646 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| CP2 | p-crm-db01 | 30643 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30643 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| OP2 | p-crm-db01 | 30649 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30649 | 1 | CRM02 | YES | SYNC | ACTIVE | |
status system replication site "1": ACTIVE
status system replication site "3": ERROR
overall system replication status: ERROR

Show that i want to detect the log file about that:
status system replication site "3": ACTIVE or ERROR.
If i search the content about that:
index=linux host="..." ("status system replication site "3": ACTIVE")
the result is :
status system replication site "1": ACTIVE
status system replication site "3": ERROR
overall system replication status: ERROR

This is false the result.
Thank

View solution in original post

0 Karma

dangtran
Explorer

Hi Giuseppe,
The full one log have 32 line. i only copy the 3 line. This is not the log. Only i export the command line to the log file and send his file to the splunk. The log content is:
| SYSTEMDB | p-crm-db01 | 30601 | nameserver | 1 | 2 | CRM01 | p-crm-db02 | 30601 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| QP2 | p-crm-db01 | 30652 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30652 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| RP2 | p-crm-db01 | 30640 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30640 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| JP2 | p-crm-db01 | 30646 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30646 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| CP2 | p-crm-db01 | 30643 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30643 | 1 | CRM02 | YES | SYNC | ACTIVE | |
| OP2 | p-crm-db01 | 30649 | indexserver | 2 | 2 | CRM01 | p-crm-db02 | 30649 | 1 | CRM02 | YES | SYNC | ACTIVE | |
status system replication site "1": ACTIVE
status system replication site "3": ERROR
overall system replication status: ERROR

Show that i want to detect the log file about that:
status system replication site "3": ACTIVE or ERROR.
If i search the content about that:
index=linux host="..." ("status system replication site "3": ACTIVE")
the result is :
status system replication site "1": ACTIVE
status system replication site "3": ERROR
overall system replication status: ERROR

This is false the result.
Thank

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi dangtran,
beware that you have quotes in your strings so you have to escape them in searches

index=linux host="..." "status system replication site \"3\": ACTIVE"

or use a rex command

index=linux host="..." | rex "status system replication site \"3\": ACTIVE"

in this way you take only the row where you have status system replication site "3": ACTIVE

Bye.
Giuseppe

0 Karma

dangtran
Explorer

Hi Giuseppe,
This working. Thank you very much.
Have good day for you.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi dangtran,
let me understand: do you want to find the first occurrance of the string status system replication site "1": ACTIVE or other?
If you want the exact string use quotes (").

There's a thing that I don't understand: you used | head 1, why you say that you received as result three strings?

status system replication site "1": ERROR
status system replication site "3": ACTIVE
overall system replication status: ERROR.

In addition, in your example there isn't any row that matches the search string, so you should not have any result.

Bye.
Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

If you're satisfied, pleace accept or upvote my answer.
By.
Giuseppe

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...

Upgrade Prep for 10.4, Network Observability Deep Dives, and More from Splunk Lantern

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

Splunk Developer Day announcements: AI agents, MCP tools, Forecasting, and Custom ...

Splunk Developer Day was packed with product and platform updates for developers building in the AI ...