Skip to content

Unable to process JSON input when ingesting logs to Oracle #333

@dushyantbhardwaj9

Description

@dushyantbhardwaj9

I am trying to ingest some data to Oracle Custom Logs. But getting Unable to process json data. I don't see any issues with the code or data i plan to ingest. I saw similar issue in donet sdk http://5.9.10.113/65091240/oracle-cloud-loggings-log-ingestion-using-oci-net-sdk-error-unable-to-proce.

data = {'hello':'oracle', 'a':'a'}

print("-"*30,str(json.dumps(data)),"-"*30)

loggingingestion_client = oci.loggingingestion.LoggingClient(config)
try:
    put_logs_response = loggingingestion_client.put_logs(
        log_id="ocid1.log.oc1.iad.amaaaaaazblm4yyashhy6l5evouqy7kyshskl2rwdhad3oniu6cf4cgs2yhq",
        put_logs_details=oci.loggingingestion.models.PutLogsDetails(
            specversion="1.0",
            log_entry_batches=[
                oci.loggingingestion.models.LogEntryBatch(
                    entries=[
                        oci.loggingingestion.models.LogEntry(
                            data= json.dumps(data),
                            id="ocid1.test.oc1..jkhjkhh23423fd")],
                    source="function",
                    type="remediationLogs",
                    defaultlogentrytime=datetime.strptime(
                        "2021-04-02T12:19:28.416Z",
                        "%Y-%m-%dT%H:%M:%S.%fZ"))]))
    print("\n\n",put_logs_response.data)

except Exception as e:
    print("\n",e)

send: b'POST /20200831/logs/ocid1.log.oc1.iad.amaaaaaazblm4yyashhy6l5evouqy7kyshskl2rwdhad3oniu6cf4cgs2yhq/actions/push HTTP/1.1\r\nuser-agent: Oracle-PythonSDK/2.32.0 (python 3.8.5; x86_64-Linux)\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nconnection: keep-alive\r\ncontent-type: application/json\r\nopc-client-info: Oracle-PythonSDK/2.32.0\r\nopc-request-id: 2FFF86E5EA7C4F9781E1DFCCB31C0E8F\r\nContent-Length: 346\r\ndate: Fri, 02 Apr 2021 10:31:30 GMT\r\nhost: ingestion.logging.us-ashburn-1.oci.oraclecloud.com\r\nx-content-sha256: m5yLuLoM24/IttlBT5xm3bWjWqrvFgIGDoNJ+Lv5QUM=\r\nauthorization: Signature algorithm="rsa-sha256",headers="date (request-target) host content-length content-type x-content-sha256",keyId="ocid1.tenancy.oc1..aaaaaaaaz4m5oix63y75wvsdaljfl75sw6udkv647xzwnk3jbkmesv73kg4q/ocid1.user.oc1..aaaaaaaa3zvd2m2b5tt3qpxwjgustesnyw72xkbh5zjedgw624lryld6pqha/5f:73:e9:5a:59:4b:91:b8:f3:b1:fd:1b:97:9b:de:81",signature="XjiQ+na29gwIm76OzpFz4lPog/jvPx63kBwXxzg4W7okXqs5KTthk1AkHgxIGbCx9YUv7fw/pybMgUzat/tTXDYlN4ec/P26uvu/w3dqnH9PSybKqlNemUFQe18zqad1Ke7qtQp2m87DWkKhHxfL2/CXh4QopAkY3nQDAK0CFSCoX3/RW0oHPD8JBW5hNxoyBlG/DG7P7zuMX7M3zxsw1G2tyK7hB0T0C73nTyXuTz/5/xbA66rTA0/UkgUIfplQHsS6WNW1rdLiA+F8+S/2oQKwUKvPvECYAa8oE/peAcMDOZOd4mmzF217OOsPaUP5dZna+rsflv0TqNPXolwp/g==",version="1"\r\n\r\n'
send: b'{"specversion": "1.0", "logEntryBatches": [{"entries": [{"data": "{\\"hello\\": \\"oracle\\", \\"a\\": \\"a\\"}", "id": "ocid1.test.oc1..jkhjkhh23423fd"}, {"data": "{\\"hello\\": \\"oracle\\", \\"a\\": \\"a\\"}", "id": "ocid1.test.oc1..jkhjkhh23423sdf34"}], "source": "function", "type": "remediationLogs", "defaultlogentrytime": "2021-04-02T12:19:28.416000Z"}]}'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Date: Fri, 02 Apr 2021 10:31:31 GMT
header: opc-request-id: 2FFF86E5EA7C4F9781E1DFCCB31C0E8F/D902F04453F98C177DBD47DCA2637DC9/B365FB7840F903C91B6A6628E32D22DD
header: Content-Type: application/json
header: Connection: close
header: Content-Length: 79

 {'opc-request-id': '2FFF86E5EA7C4F9781E1DFCCB31C0E8F/D902F04453F98C177DBD47DCA2637DC9/B365FB7840F903C91B6A6628E32D22DD', 'code': 'InvalidParameter', 'message': 'Unable to process JSON input', 'status': 400}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions