Coder Social home page Coder Social logo

apisnoopregexp's Introduction

apisnoopregexp

Clone API snoop database

  • Create local postgres database: sudo -u postgres psql: create database hh;.
  • Initialize database structure: sudo -u postgres psql hh < structure.sql.
  • Dump api_operations table data into a local TSV file: psql -h apisnoop-db-host -U apisnoop-db-user hh -tAc "\copy (select * from api_operations) to '/tmp/api_operations.tsv'".
  • Dump audit_events table data into a local TSV file: psql -h apisnoop-db-host -U apisnoop-db-user hh -tAc "\copy (select * from audit_events) to '/tmp/audit_events.tsv'".
  • Restore api_operations table data locally: sudo -u postgres psql hh -tAc "\copy api_operations from '/tmp/api_operations.tsv'".
  • Restore audit_events table data locally: sudo -u postgres psql hh -tAc "\copy audit_events from '/tmp/audit_events.tsv'".

Update OpID via Regexp

Note that all mass update script only update records with null on opid, so they can be called iteratively.

  • Run: make, time sudo -u postgres ./rmatch. That will update op_id column on audit_events table.
  • You can use CONN='....' to specify your own custom connect string, see example connect strings in lib.go.
  • You can use ANALYSIS=1 to get information about how many records had 0, 1, 2, ... matches.
  • You can use DBG=1 to get a lot more verbose output.

Restore into the original database

  • Generate SQL file to be run on the original database: make, time sudo -u postgres ./gensql > update.sql.
  • Run script on the original database: psql -h apisnoop-db-host -U apisnoop-db-user hh < update.sql.

You can also generate TSV dumps from your local databae and restore them on the remote, but the above solution is faster and better

  • Dump api_operations table data into a local TSV file: sudo -u postgres psql hh -tAc "\copy (select * from api_operations) to '/tmp/new_api_operations.tsv'".
  • Dump audit_events table data into a local TSV file: sudo -u postgres psql hh -tAc "\copy (select * from audit_events) to '/tmp/new_audit_events.tsv'".

apisnoopregexp's People

Contributors

lukaszgryglicki avatar

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.