oracle / oci-python-sdk

Oracle Cloud Infrastructure SDK for Python
https://cloud.oracle.com/cloud-infrastructure
Other
378 stars 272 forks source link

Search Logs model oci.loggingsearch.models.SearchLogsDetails InvalidParameter #338

Closed henryhormaza closed 2 years ago

henryhormaza commented 3 years ago

Hi, I'm getting an error when trying to access to a log search: this is the syntax that I'm usign according to the example in the documentation:

https://docs.oracle.com/en-us/iaas/tools/python-sdk-examples/2.35.1/loggingsearch/search_logs.py.html

    search_logs_response = oci_obj.o_loggingsearch.search_logs(
        search_logs_details=oci.loggingsearch.models.SearchLogsDetails(
            time_start=datetime.datetime.strptime(
                "2021-04-13T23:10:47.585062Z",
                "%Y-%m-%dT%H:%M:%S.%fZ"),
            time_end=datetime.datetime.strptime(
                "2021-04-13T23:14:47.585062Z",
                "%Y-%m-%dT%H:%M:%S.%fZ"),
            search_query='search \"ocid1.compartment.oc1..aaaaaaaSOMEOCID\" | type=\'com.oraclecloud.vcn.flowlogs.DataEvent\' | sort by datetime desc'),
        limit=500)

For some reason it keeps telling that the parameters are incorrect, is it a bug? or just an outdated documentation ?


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "~/.local/lib/python3.9/site-packages/oci/loggingsearch/log_search_client.py", line 162, in search_logs
    return self.base_client.call_api(
  File "~/.local/lib/python3.9/site-packages/oci/base_client.py", line 279, in call_api
    response = self.request(request)
  File "~/.local/lib/python3.9/site-packages/oci/base_client.py", line 391, in request
    self.raise_service_error(request, response)
  File "~/.local/lib/python3.9/site-packages/oci/base_client.py", line 556, in raise_service_error
    raise exceptions.ServiceError(
oci.exceptions.ServiceError: {'opc-request-id': 'E6236AD6EE4D4E03AECBC51842540FCF/6742863030A19B864A6E044889ACCA1A/84F75CD2CBA9523586F6B8AA2FA8C784', 'code': 'InvalidParameter', 'message': 'Unable to process JSON input', 'status': 400}
`
petro-boychuk commented 3 years ago

@henryhormaza try limiting the date format to three digits after the decimal point.

henryhormaza commented 3 years ago

@henryhormaza try limiting the date format to three digits after the decimal point.

No, already tried, but I get the same results

mgutierr22abr commented 3 years ago

I tried even with all fields calculated and got the same error loggingsearch_client.search_logs( search_logs_details=oci.loggingsearch.models.SearchLogsDetails( time_start=datetime.datetime.now(datetime.timezone.utc).astimezone() - datetime.timedelta(minutes=66), time_end=datetime.datetime.now(datetime.timezone.utc).astimezone() - datetime.timedelta(minutes=1), search_query="search \"ocid1.compartment.oc1..aaaaaaaa7ueohzih5yhxfzdo3z5wsvzcu5dulsbm44ze26544adap5ekozsq\"", is_return_field_info=False), limit=20 )

jodoglevy commented 2 years ago

Hi @mgutierr22abr and @henryhormaza - I talked to @petro-boychuk today, we think this issue is now resolved. There was a limitation in the Logging Search service in terms of the datetime precision supported, but that precision has now been expanded to support the full RFC3339Nano spec.

I'm going to close this issue, but if you are still experiencing the problem, please feel free to reopen