googleapis/python-logging

Error when using ListLogEntriesRequest method

luigi-bitonti opened this issue · 1 comments

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Debian GNU/Linux 12 (bookworm)
  • Python version: python --version Python 3.11.2
  • pip version: pip --version pip 23.0.1
  • google-cloud-logging version: pip show google-cloud-logging 3.10.0

Steps to reproduce

  1. Create a script with the following snippet
  2. Launch

Code example

    client = logging_v2.services.logging_service_v2.LoggingServiceV2Client()

    start_datetime = datetime(2024, 7, 1, 22, 33, 0)  # 13:00  13 marzo 2023
    end_datetime = datetime(2024, 7, 1, 22, 40, 0)  # 13:04 13 marzo 2023

    start_timestamp = timestamp_pb2.Timestamp()
    start_timestamp.FromDatetime(start_datetime)
    end_timestamp = timestamp_pb2.Timestamp()
    end_timestamp.FromDatetime(end_datetime)

    print(start_timestamp)


    request = logging_v2.types.ListLogEntriesRequest(
        resource_names=['projects/test-lb-XXXXX/locations/europe-west3/buckets/test2/view/my_view'],

        filter=f'timestamp >= "{start_timestamp.ToJsonString()}" AND timestamp < "{end_timestamp.ToJsonString()}" AND jsonPayload.@type=type.googleapis.com/google.cloud.servicehealth.logging.v1.EventLog'
    )
            # Make the request
    page_result = client.list_log_entries(request=request)

Stack trace

google.api_core.exceptions.InvalidArgument: 400 Expected a resource of the form projects/[PROJECT_ID] or folders/[FOLDER_ID] or organizations/[ORGANIZATION_ID] or billingAccounts/[BILLING_ACCOUNT_ID] [reason: "LOGGING_ERROR_QUERY_INVALID_RESOURCE_NAME"
domain: "logging.googleapis.com"
metadata {
  key: "resource"
  value: "projects/test-lb-XXXXX/locations/europe-west3/buckets/test2/view/my_view"
}

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

I close the issue, I did a mistake: resource_names=['projects/test-lb-XXXXX/locations/europe-west3/buckets/test2/views/my_view'], I missed an "s".