@Rohit_809 Kumar My apologies. I was trying to say that the “text” column and he “match” column were temporary columns. They are there for the troubleshooting. If you are only seeing data in the “text” column, but not in the “match” column, then it means you “pattern01” is not working yet.
You need to keep adjusting you “pattern01” until you receive output in the “match” column. Once you see output in the “match” column. Then you are ready to take the final step and remove the “let match” and go back to that being just a “foreach” statement. Then you can put the data you want into other columns.
This is what the query looks like when you are troubleshooting.
pattern01 =
```
Ltm::VirtualServer: {VirtualServer:string}
Status
Availability : {Availability:string}
State : {State:string}
Reason : {Reason:(string*)}
Destination : {Destination:string}
```;
foreach device in network.devices
where device.platform.vendor == Vendor.F5
where device.snapshotInfo.result == DeviceSnapshotResult.completed
foreach command in device.outputs.commands
where command.commandType == CommandType.F5_VIRTUAL_SERVER_STATE
let text = command.response
let text = replaceMatches(text, "\n", "\n ")
let text = replaceMatches(text, " Ltm::Virtual Server: ", "Ltm::VirtualServer: ")
let parsedCommand = parseConfigBlocks(OS.F5, text)
let match = (foreach match in blockMatches(parsedCommand, pattern01) select match) // this line is temporary for troubleshooting
// foreach match in blockMatches(parsedCommand, pattern01) // commented out for troubleshooting
select {
device: device.name,
match, // temporary for troubleshooting
text, // temporary for troubleshooting
/* Uncomment the following lines after you get the match working
* And after you comment out the "let match" line in the body of the query
VirtualServer: match.data.VirtualServer,
Availability: match.data.Availability,
State: match.data.State,
Reason: join(" ", match.data.Reason),
"IP Address": match.data.Destination
*/
}
This is what it would look like when you think your “pattern01” is correct.
pattern01 =
```
Ltm::VirtualServer: {VirtualServer:string}
Status
Availability : {Availability:string}
State : {State:string}
Reason : {Reason:(string*)}
Destination : {Destination:string}
```;
foreach device in network.devices
where device.platform.vendor == Vendor.F5
where device.snapshotInfo.result == DeviceSnapshotResult.completed
foreach command in device.outputs.commands
where command.commandType == CommandType.F5_VIRTUAL_SERVER_STATE
let text = command.response
let text = replaceMatches(text, "\n", "\n ")
let text = replaceMatches(text, " Ltm::Virtual Server: ", "Ltm::VirtualServer: ")
let parsedCommand = parseConfigBlocks(OS.F5, text)
// let match = (foreach match in blockMatches(parsedCommand, pattern01) select match) // this line is temporary for troubleshooting
foreach match in blockMatches(parsedCommand, pattern01) // commented out for troubleshooting
select {
device: device.name,
// match, // temporary for troubleshooting
// text, // temporary for troubleshooting
/* Uncomment the following lines after you get the match working
* And after you comment out the "let match" line in the body of the query */
VirtualServer: match.data.VirtualServer,
Availability: match.data.Availability,
State: match.data.State,
Reason: join(" ", match.data.Reason),
"IP Address": match.data.Destination
/* */
}
Then this would hopefully be the final product after you take out the lines you used for troubleshooting.
pattern01 =
```
Ltm::VirtualServer: {VirtualServer:string}
Status
Availability : {Availability:string}
State : {State:string}
Reason : {Reason:(string*)}
Destination : {Destination:string}
```;
foreach device in network.devices
where device.platform.vendor == Vendor.F5
where device.snapshotInfo.result == DeviceSnapshotResult.completed
foreach command in device.outputs.commands
where command.commandType == CommandType.F5_VIRTUAL_SERVER_STATE
let text = command.response
let text = replaceMatches(text, "\n", "\n ")
let text = replaceMatches(text, " Ltm::Virtual Server: ", "Ltm::VirtualServer: ")
let parsedCommand = parseConfigBlocks(OS.F5, text)
foreach match in blockMatches(parsedCommand, pattern01)
select {
device: device.name,
VirtualServer: match.data.VirtualServer,
Availability: match.data.Availability,
State: match.data.State,
Reason: join(" ", match.data.Reason),
"IP Address": match.data.Destination
}
I hope this helps.