Knowledge Management

macro with DBquery

senthilgoa
Engager

Hi
I used macro and its return some results, I want to run dbquery to passing parameter using the macro results
How can i run the Splunk query

example

`testmacro` | map search = "dbquery Database \"SELECT [Change_ID],[Approval_Status_Overall],[Approval_Status_Current],[Assignment_Change_Assignee] FROM [ARSystem].[dbo].[A_Reporting_CHG_Infrastructure_Change_Base_Datamart_AllOpen] where host = $A$\""

here macro result was Asd23400SA
testmacro

Senthil.R

Tags (2)
0 Karma

senthilgoa
Engager

Macroname : DB_changes_by_org_grp
macro Content : dbquery DB "SELECT * FROM [ARSystem].[dbo].[A_Reporting_CHG_Infrastructure_Change_Base_Datamart_AllOpen] "
Description : fetches data form SQL

macro name : group
| eval so = "$source$" | eval X =replace(so, "group=", "(Assignment_Support_Group_Name LIKE \"") |eval X =replace(X, "org=", "(Assignment_Support_Organization LIKE \"") | eval Y =replace(X,",", "%\") OR ")|eval Y=Y."%\")"
Description : evaluate where condition based on parameter (splunk where condition)

Final Query
|DB_changes_by_org_grp| where group("group=DBA,org=EAWS,group=Appl,org=PTG")

Description : I wnat run final query like this
dbquery DB "SELECT * FROM [ARSystem].[dbo].[A_Reporting_CHG_Infrastructure_Change_Base_Datamart_AllOpen] " |where (Assignment_Support_Group_Name LIKE "DBA%") OR (Assignment_Support_Organization LIKE "EAWS%") OR (Assignment_Support_Group_Name LIKE "Appl%") OR (Assignment_Support_Organization LIKE "PTG%")

we formed a query but we cant able to run this guery and get the results

0 Karma

BP9906
Builder

I'm having the same issue. I reported it here:
http://answers.splunk.com/answers/114566/dbquery-command-with-map-command

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Is the macro eval based? Can you post the macro content?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...