turbot / steampipe-plugin-oci

Use SQL to instantly query Oracle Cloud resources across regions and accounts. Open source CLI. No DB required.
https://hub.steampipe.io/plugins/turbot/oci
Apache License 2.0
18 stars 5 forks source link

support for query log-file contents #482

Closed lucasjellema closed 1 year ago

lucasjellema commented 1 year ago

Is your feature request related to a problem? Please describe. I was looking at oci_logging_log and I noticed it does not cover the actual contents of log files. I was wondering if perhaps there can be support for queries against log-file contents.

I was checking out the Oracle supported Grafana plugin https://github.com/oracle/oci-grafana-logs that provides such support through Grafana and all of a sudden it seems doable. Specifically file https://github.com/oracle/oci-grafana-logs/blob/main/pkg/datasource.go provides quite a bit of insight into how this could be done

Describe the solution you'd like The ability to select lines from logs that satisfy conditions (regarding log , start and end timestamp, level and search string)

Whether this should be a new table or be integrated into oci_logging_log I am note. However, while writing this down, perhaps a new table does make most sense - something like oci_logging_log_entries.

Some references:

https://github.com/oracle/oci-go-sdk/blob/v65.28.0/loggingsearch/loggingsearch_logsearch_client.go, https://pkg.go.dev/github.com/oracle/oci-go-sdk/v65@v65.28.0/loggingsearch#SearchLogsResponse https://github.com/oracle/oci-grafana-logs/blob/main/pkg/datasource.go

misraved commented 1 year ago

Thanks @lucasjellema for raising this issue 👍.

The analysis makes sense. We need to check if the corresponding API for log entries supports pagination or not. If yes, then it is safe to create a new table for it.

Does terraform have any references to the log entries?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

bigdatasourav commented 1 year ago

@lucasjellema, sorry for the delayed response.

We are actively investigating and conducting thorough testing of the above API using various test cases. You can find all the relevant details here. We welcome your feedback and suggestions as we continue working on this.

bigdatasourav commented 1 year ago

Based on the documentation and my investigation of the API, I have compiled the following findings: [branch link]

@cbruno10 please provide your thoughts.

cbruno10 commented 1 year ago

@bigdatasourav Thanks for doing research into the API, my responses are below:

bigdatasourav commented 1 year ago

LogContent response structure is not consistent -

 {                                                                                                                                                                                        
     "id": "c45ef0a9-2be2-4365-b957-1087af3f5ed0",                                                                                                                                        
     "data": {                                                                                                                                                                            
         "isPar": false,                                                                                                                                                                  
         "region": "us-ashburn-1",                                                                                                                                                        
         "apiType": "native",                                                                                                                                                             
         "endTime": "2023-07-12T04:10:23.230Z",                                                                                                                                           
         "message": "List of Objects retrieved.",                                                                                                                                         
         "bucketId": "ocid1.bucket.oc1.iad.aaaaaaaab7flmnz4bs7itdxureoguhucq5ihbm6whc35h4lpa",                                                                                 
         "tenantId": "ocid1.tenancy.oc1..aaaaaaaahnm7gleh5soecxzjetci3yjjnjqmfh2q37cyljaq",                                                                                   
         "startTime": "2023-07-12T04:10:23.204Z",                                                                                                                                         
         "userAgent": "Oracle-GoSDK/65.28.0 (linux/amd64; go/go1.19.10)",                                                                                                                 
         "bucketName": "bucket-20230710-1243",                                                                                                                                            
         "statusCode": 200,                                                                                                                                                               
         "tenantName": "turbot",                                                                                                                                                          
         "credentials": "ocid1.tenancy.oc1..aaaaaaaahnm7gleh5soecxzjetci3yjjnjqmfk2q37cyljaq/ocid1.user.oc1..aaaaaaaaydv22bk4pk5uwk6boif7mbbvy7kvb6sb572cpsvpitq/4a:c
         "principalId": "ocid1.user.oc1..aaaaaaaaydv22bk4p5hh7x3pcvk5uwk6boif7mbbvy72cpsvpitq",                                                                                   
         "opcRequestId": "iad-1:al2nT_y2mbXJ8ZVeNju-NaK4kM_ta3OMWm3f6rEnMwr-KQtIOMTb018byk4Y27GP",                                                                                        
         "bucketCreator": "ocid1.user.oc1..aaaaaaaazvio4hcyouxn2zd5latufffwyuwja7mwuj3x6pq4i2q",                                                                                 
         "compartmentId": "ocid1.tenancy.oc1..aaaaaaaahnm7gleh5soecxzjetci3yjjnjqmfk4p4h2q37cyljaq",                                                                              
         "namespaceName": "bmqeqvslavsz",                                                                                                                                                 
         "principalName": "SteampipeResourceListBot",                                                                                                                                     
         "requestAction": "GET",                                                                                                                                                          
         "clientIpAddress": "104.45.202.149",                                                                                                                                             
         "compartmentName": "turbot",                                                                                                                                                     
         "authenticationType": "user",                                                                                                                                                    
         "requestResourcePath": "/n/bmqeqvslavsz/b/bucket-20230710-1243/o?fields=name%2Csize%2Cetag%2CtimeCreated%2Cmd5%2CtimeModified%2CstorageTier%2CarchivalState&limit=1000"          
     },                                                                                                                                                                                   
     "time": "2023-07-12T04:10:23.230Z",                                                                                                                                                  
     "type": "com.oraclecloud.objectstorage.listobjects",                                                                                                                                 
     "oracle": {                                                                                                                                                                          
         "logid": "ocid1.log.oc1.iad.amaaaaaa6igdexaahbhu27du77j6ptteohx57m7pj6fpn5m6cq",                                                                                       
         "tenantid": "ocid1.tenancy.oc1..aaaaaaaahnm7gleh5soecxzjetci3yjjnjqmp4h2q37cyljaq",                                                                                   
         "loggroupid": "ocid1.loggroup.oc1.iad.amaaaaaa6igdexaa2xbvm6hxx22nelt7j7w3c5sekrlwp7z5spvzrq",                                                                             
         "ingestedtime": "2023-07-12T04:10:44.503Z",                                                                                                                                      
         "compartmentid": "ocid1.tenancy.oc1..aaaaaaaahnm7gleh5soecxzjetci3yjjnjqmfkr4p4h2q37cyljaq"                                                                               
     },                                                                                                                                                                                   
     "source": "bucket-20230710-1243",                                                                                                                                                    
     "specversion": "1.0"                                                                                                                                                                 
 }

We are going to design the table below way -