Giter VIP home page Giter VIP logo

gcp-logging-retrieved's Introduction

gcp-logging-retrieved

Retrieve logs from Cloud logging

Requirements

  • Python 3.6+

Setup

  1. Create configuration file
$ touch config.yaml
$ vi config.yaml

startTime: "2021-03-01T00:00:00.000Z"
endTime: "2021-03-01T03:00:00.000Z"
# google cloud logging query statement
queryStatement: 'resource.type="k8s_container" resource.labels.cluster_name="dev-test-gke-cluster" resource.labels.namespace_name="test-ns" resource.labels.container_name="dev-project"'
#filter logs
field: 'textPayload'
# The script breaks down time range into several small intervals to speed up, decrease the value if google api limit is exceeded.
interval: 90
# multiprocessing
maxWorkers: 4
  1. Google authentication

a. Using environment variable

  • GCP Dashboard > IAM&Admin > Services Accounts > Create a service account with Logging Admin role
$ export GOOGLE_APPLICATION_CREDENTIALS=<<PATH_TO_SERVICE_ACCOUNT_JSON_FILE>>

b. Using json file

Save service account json file (keyfile.json) in executable script or binary

c. Using gcloud

$ gcloud init
$ gcloud auth application-default login
  1. Run the script
$ pip install -r requirements.txt
$ python main.py -h
$ python main.py

Execute as binary file in Mac OSX

$ curl -L https://github.com/bangnh1/gcp-logging-retrieved/releases/download/v0.0.1/gcp-logging-retrieved -o gcp-logging-retrieved
$ export GOOGLE_APPLICATION_CREDENTIALS=<<PATH_TO_SERVICE_ACCOUNT_JSON_FILE>>
$ ./gcp-logging-retrieved -c config.yaml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.