question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot parse getEntries data buffer

See original GitHub issue

We’re trying to get entries for some logs, when we fetch entries it seems that the data is represented by some buffer that we cant convert, we guess that it is related somehow to the proto files or it might be that the buffer is corrupt?

async function listLogEntries(logName) {
    const { Logging } = require('@google-cloud/logging');
    const logging = new Logging({ projectId: projectId, credentials: cred });
    const log = logging.log(logName);

    async function printEntryMetadata() {
        const [entries] = await log.getEntries({
            filter: 'logName="SOME_LOG_NAME"', pageSize: 5
        });
        console.log('Logs:');
        entries.forEach(entry => {
           console.log(entry.data.value;) // Buffer
        });
    }
    printEntryMetadata();
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mor-cloudwizecommented, Feb 7, 2021

Hi, thanks for the reply, I still can’t get a valid value from the payload:

const logName = 'cloudaudit.googleapis.com%2Factivity';
async function main(scope, query, assetTypes, pageSize, pageToken, orderBy) {
    // Imports the Google Cloud client library
    const { Logging } = require('@google-cloud/logging');

    // Creates a client
    const logging = new Logging({ projectId, credentials: cred });
    const logName = 'cloudaudit.googleapis.com%2Factivity';
    const log = logging.log(logName);

    async function printEntryMetadata() {
        log.getEntries().then(data => {
            return data[0]
        }).then((entries) => {
            console.log('Logs:');
            entries.forEach(entry => {
                const metadata = entry.metadata;
                console.log(`${metadata.timestamp}:`, metadata[metadata.payload].value.toString());
            });
        });
    }
    printEntryMetadata();
}

main(...process.argv.slice(2)).catch(err => {
    console.error(err.message);
    process.exitCode = 1;
})

Im adding one of the results printed in console:


2billing-export-bigquery@system.gserviceaccount.com":B:bigquery.googleapis.comB1google.cloud.bigquery.v2.TableService.UpdateTableJ�
fprojects/<<project-id>>/datasets/<<company-name>>_billing/tables/gcp_billing_export_v1_0170A2_15340F_FDCB33bigquery.tables.update*Zfprojects/<<project-id>>/datasets/<<company-name>>_billing/tables/gcp_billing_export_v1_0170A2_15340F_FDCB33��)
G
@type><type.googleapis.com/google.cloud.audit.BigQueryAuditMetadata
�(

tableChange�(*�(
�(
table�'*�'
�&

schemaJson�&�&{
  "fields": [{
    "name": "billing_account_id",
    "type": "STRING",
    "mode": "NULLABLE"
  }, {
    "name": "service",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "description",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "sku",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "description",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "usage_start_time",
    "type": "TIMESTAMP",
    "mode": "NULLABLE"
  }, {
    "name": "usage_end_time",
    "type": "TIMESTAMP",
    "mode": "NULLABLE"
  }, {
    "name": "project",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "number",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "name",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "labels",
        "type": "RECORD",
        "mode": "REPEATED",
        "schema": {
          "fields": [{
            "name": "key",
            "type": "STRING",
            "mode": "NULLABLE"
          }, {
            "name": "value",
            "type": "STRING",
            "mode": "NULLABLE"
          }]
        }
      }, {
        "name": "ancestry_numbers",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "labels",
    "type": "RECORD",
    "mode": "REPEATED",
    "schema": {
      "fields": [{
        "name": "key",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "value",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "system_labels",
    "type": "RECORD",
    "mode": "REPEATED",
    "schema": {
      "fields": [{
        "name": "key",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "value",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "location",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "location",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "country",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "region",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "zone",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "export_time",
    "type": "TIMESTAMP",
    "mode": "NULLABLE"
  }, {
    "name": "cost",
    "type": "FLOAT",
    "mode": "NULLABLE"
  }, {
    "name": "currency",
    "type": "STRING",
    "mode": "NULLABLE"
  }, {
    "name": "currency_conversion_rate",
    "type": "FLOAT",
    "mode": "NULLABLE"
  }, {
    "name": "usage",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "amount",
        "type": "FLOAT",
        "mode": "NULLABLE"
      }, {
        "name": "unit",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "amount_in_pricing_units",
        "type": "FLOAT",
        "mode": "NULLABLE"
      }, {
        "name": "pricing_unit",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "credits",
    "type": "RECORD",
    "mode": "REPEATED",
    "schema": {
      "fields": [{
        "name": "name",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "amount",
        "type": "FLOAT",
        "mode": "NULLABLE"
      }, {
        "name": "full_name",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "type",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "invoice",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "month",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }, {
    "name": "cost_type",
    "type": "STRING",
    "mode": "NULLABLE"
  }, {
    "name": "adjustment_info",
    "type": "RECORD",
    "mode": "NULLABLE",
    "schema": {
      "fields": [{
        "name": "id",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "description",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "mode",
        "type": "STRING",
        "mode": "NULLABLE"
      }, {
        "name": "type",
        "type": "STRING",
        "mode": "NULLABLE"
      }]
    }
  }]
}
(

updateTime2020-11-09T20:02:55.628Z
(

createTime2019-03-24T18:47:10.559Z
u
        tableNamehfprojects/<<project-id>>/datasets/<<company-name>>_billing/tables/gcp_billing_export_v1_0170A2_15340F_FDCB33
 
reasonTABLE_UPDATE_REQUEST

You can see the value is not valid, am i missing something or doing something wrong?

0reactions
mynameisnykecommented, Oct 20, 2021

Resurfacing this, i’ve tried the suggestions in this thread, but also the suggestions in #785.

For my project, I need to get the authenticationInfo.principalEmail which is nested inside of protoPayload key, however as others have found this property comes out as a buffer. I understand that there’s the option to leverage a sink, but this is something we want to do across of all of the projects in our organization and would prefer to not have to build a sink every-time if at all possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript JSON parse problem with decoded POST request ...
I get base64 data as an answer to a POST request. It's decoded the following way (based on the documentation of the REST...
Read more >
Troubleshooting Amazon Kinesis Data Firehose
If Kinesis Data Firehose encounters errors while delivering or processing data, it retries until the configured retry duration expires.
Read more >
Node.js v19.3.0 Documentation
When encoding a Buffer to a string, this encoding will omit padding. 'hex' : Encode each byte as two hexadecimal characters. Data truncation...
Read more >
INTERNAL error: Cannot parse the client information buffer.
I am getting this on several clients when attempting to "check installation" or when trying to "update" from the client view in DP...
Read more >
Chapter: Trees - ROOT - CERN
When using a TTree , we fill its branch buffers with leaf data and the ... By default, GetEntry() reuses the space allocated...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found