项目作者: globalundo

项目描述 :
multicorn wrapper for datadog :corn::dog:
高级语言: Python
项目地址: git://github.com/globalundo/corndog.git
创建时间: 2017-06-08T18:31:22Z
项目社区:https://github.com/globalundo/corndog

开源协议:

下载


corndog :corn::dog:

multicorn wrapper for datadog

multiCORNdataDOG

Install (essentials)

  1. sudo apt-get install python-dev pgxnclient
  2. sudo pgxn install multicorn
  3. git clone https://github.com/globalundo/corndog
  4. cd corndog
  5. python setup.py install

Install from scratch on debian jessie

  1. # Add postgresql.ord repo
  2. # https://wiki.postgresql.org/wiki/Apt
  3. sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
  4. sudo apt-get install wget ca-certificates
  5. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
  6. sudo apt-get update
  7. sudo apt-get install postgresql-9.6 postgresql-server-dev-9.6
  8. sudo apt-get install python-dev pgxnclient
  9. sudo apt-get install git
  10. git clone https://github.com/globalundo/corndog
  11. cd corndog
  12. python setup.py install
  13. #sudo sed -i 's/local all postgres peer/local all all trust/g' /etc/postgresql/9.6/main/pg_hba.conf
  14. #sudo sed -i "s/#listen_addresses.*/listen_addresses = '*'/g" /etc/postgresql/9.6/main/postgresql.conf
  15. #sudo sed -i 's|host.*|host all all 127.0.0.1/32 trust|g' /etc/postgresql/9.6/main/pg_hba.confsudo service postgresql restart
  16. #psql -U postgres <<EOF
  17. #CREATE DATABASE datadog;
  18. #\c datadog
  19. #CREATE EXTENSION multicorn;
  20. #CREATE SERVER corndog FOREIGN DATA WRAPPER multicorn
  21. #options (
  22. # wrapper 'corndog.DatadogForeignDataWrapper',
  23. # api_key 'YOUR_API_KEY_HERE',
  24. # app_key 'YOUR_APP_KEY_HERE'
  25. #);
  26. #CREATE FOREIGN TABLE metrics (
  27. # timestamp float,
  28. # value float,
  29. # startdate int,
  30. # enddate int,
  31. # query text,
  32. # scope text
  33. #) server corndog ;
  34. #select * from metrics limit 1;
  35. #select * from metrics where query='system.cpu.user{*}' limit 1;
  36. #select timestamp, value from metrics where query='system.cpu.user{*}' and startdate = extract(epoch from (now()-'20 days'::interval))::int;
  37. #select timestamp, value from metrics where query='system.cpu.user{*}' and startdate = extract(epoch from (now()-'12 hours'::interval))::int and enddate = extract(epoch from (now()-'2 hours'::interval))::int;
  38. #
  39. #EOF

Usage

  1. CREATE EXTENSION multicorn;
  2. CREATE SERVER corndog FOREIGN DATA WRAPPER multicorn
  3. options (
  4. wrapper 'corndog.DatadogForeignDataWrapper',
  5. api_key 'YOUR_API_KEY_HERE',
  6. app_key 'YOUR_APP_KEY_HERE'
  7. );
  8. CREATE FOREIGN TABLE metrics (
  9. timestamp float,
  10. value float,
  11. startdate int,
  12. enddate int,
  13. query text,
  14. scope text
  15. ) server corndog;
  16. select * from metrics limit 1;
  17. select * from metrics where query='system.cpu.user{*}' limit 1;
  18. select timestamp, value from metrics where query='system.cpu.user{*}' and startdate = extract(epoch from (now()-'20 days'::interval))::int;
  19. select timestamp, value from metrics where query='system.cpu.user{*}' and startdate = extract(epoch from (now()-'12 hours'::interval))::int and enddate = extract(epoch from (now()-'2 hours'::interval))::int;