{"id":13517538,"url":"https://github.com/box/Anemometer","last_synced_at":"2025-03-31T08:31:45.437Z","repository":{"id":2810977,"uuid":"3812233","full_name":"box/Anemometer","owner":"box","description":"Box SQL Slow Query Monitor","archived":false,"fork":false,"pushed_at":"2021-12-08T23:39:55.000Z","size":1546,"stargazers_count":1391,"open_issues_count":60,"forks_count":314,"subscribers_count":118,"default_branch":"develop","last_synced_at":"2025-03-25T02:39:37.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/box.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-03-23T20:21:30.000Z","updated_at":"2025-03-15T20:58:20.000Z","dependencies_parsed_at":"2022-09-20T00:05:51.024Z","dependency_job_id":null,"html_url":"https://github.com/box/Anemometer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2FAnemometer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2FAnemometer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2FAnemometer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/box%2FAnemometer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/box","download_url":"https://codeload.github.com/box/Anemometer/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246441632,"owners_count":20778069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T05:01:34.828Z","updated_at":"2025-03-31T08:31:44.033Z","avatar_url":"https://github.com/box.png","language":"JavaScript","funding_links":[],"categories":["分析工具","JavaScript","Database","服务端测试","Analysis"],"sub_categories":["服务端监控"],"readme":"\nBox Anemometer\n--------------\n[![Project Status](http://opensource.box.com/badges/maintenance.svg)](http://opensource.box.com/badges)\n[![Travis](https://img.shields.io/travis/box/Anemometer.svg?maxAge=2592000)](https://travis-ci.org/box/Anemometer)\n[![Join the chat at https://gitter.im/box/Anemometer](https://badges.gitter.im/box/Anemometer.svg)](https://gitter.im/box/Anemometer?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nThis is the Box Anemometer, the MySQL Slow Query Monitor.  This tool is used to analyze slow query logs collected from MySQL instances to identify problematic queries.\n\n### Documentation ###\n\n1.\t[What is Anemometer?](https://github.com/box/Anemometer/wiki)\n2.\t[Extra Features](https://github.com/box/Anemometer/wiki/Extra-Features)\n3.\t[Using PERFORMANCE_SCHEMA](https://github.com/box/Anemometer/wiki/Using-PERFORMANCE_SCHEMA-in-MySQL-5.6)\n4.\t[Collection Script](https://github.com/box/Anemometer/wiki/Anemometer-Collection-Script)\n5.\t[Development with Vagrant](https://github.com/box/Anemometer/wiki/Development-with-Vagrant)\n6.\tInstallation: See Quickstart below\n7.  [Unit Testing](https://github.com/box/Anemometer/wiki/Unit-Testing)\n\n### Quickstart ###\n\nIf you're just completely itching to start using this tool, here's what you need:\n\n1.\ta MySQL database to store query analysis data in.\n2.\t[pt-query-digest](http://www.percona.com/doc/percona-toolkit/pt-query-digest.html).\n\t*\tYou may as well just get the whole [Percona Toolkit](http://www.percona.com/doc/percona-toolkit) while you're at it :)\n3.\ta slow query log from a MySQL server (see [The Slow Query Log](http://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html) for info on getting one)\n4.\ta webserver with PHP 5.5+\n\n\n#### Setup DB ####\n\nFirst up, grab the anemometer code from github. Navigate to the document root of your web server and snag a copy of the Box Anemometer code.\n\n    $ git clone git://github.com/box/Anemometer.git anemometer \nOr, if you have 9418 port closed:\n\n    $ git clone https://github.com/box/Anemometer.git anemometer \n\n\nThen change your current working directory to the Anemometer directory:\n\n    $ cd anemometer\n    \nNext, you should connect to the MySQL database you're looking to store the analysis data in and issue the following command:\n\n    $ mysql -h db.example.com \u003c install.sql\n    $ mysql -h db.example.com -e \"grant ALL ON slow_query_log.* to 'anemometer'@'%' IDENTIFIED BY 'superSecurePass';\"\n\n#### Put some data in the DB ####\n\nNext, grab that slow query log file you have (mine's called \"slow.log\"!), and run pt-query-digest on it:\n**NOTE:** I'm using a BASH 3.0 shell here on my MySQL database server! This is so the \"$HOSTNAME\" variable properly replaces with \"db.example.com\")\n\n\nFor pt-query-digest version \u003c 2.2\n\n    $ pt-query-digest --user=anemometer --password=superSecurePass \\\n                      --review h=db.example.com,D=slow_query_log,t=global_query_review \\\n                      --review-history h=db.example.com,D=slow_query_log,t=global_query_review_history \\\n                      --no-report --limit=0% \\ \n                      --filter=\" \\$event-\u003e{Bytes} = length(\\$event-\u003e{arg}) and \\$event-\u003e{hostname}=\\\"$HOSTNAME\\\"\" \\ \n                      /var/lib/mysql/db.example.com-slow.log\n    \n\nFor pt-query-digest version \u003e= 2.2\n\n    $ pt-query-digest --user=anemometer --password=superSecurePass \\\n                      --review h=db.example.com,D=slow_query_log,t=global_query_review \\\n                      --history h=db.example.com,D=slow_query_log,t=global_query_review_history \\\n                      --no-report --limit=0% \\ \n                      --filter=\" \\$event-\u003e{Bytes} = length(\\$event-\u003e{arg}) and \\$event-\u003e{hostname}=\\\"$HOSTNAME\\\"\" \\ \n                      /var/lib/mysql/db.example.com-slow.log\n\n\n    Pipeline process 11 (aggregate fingerprint) caused an error: Argument \"57A\" isn't numeric in numeric gt (\u003e) at (eval 40) line 6, \u003c\u003e line 27.\n    Pipeline process 11 (aggregate fingerprint) caused an error: Argument \"57B\" isn't numeric in numeric gt (\u003e) at (eval 40) line 6, \u003c\u003e line 28.\n    Pipeline process 11 (aggregate fingerprint) caused an error: Argument \"57C\" isn't numeric in numeric gt (\u003e) at (eval 40) line 6, \u003c\u003e line 29.\n\nYou may see an error like above, that's okay!\nTODO: explain what the options above are doing.\n\n\n#### View the data! ####\n\nNow, navigate to the document root of your web server and copy the sample config so you can edit it:\n\n    $ cd anemometer/conf\n    $ cp sample.config.inc.php config.inc.php \n\n\nThe sample config explains every setting you may want to change in it.  At the very least, make sure you set the Datasource to the MySQL database you're storing the analyzed digest information in:\n\n    $conf['datasources']['localhost'] = array(\n    \t'host'\t=\u003e 'db.example.com',\n    \t'port'\t=\u003e 3306,\n    \t'db'\t=\u003e 'slow_query_log',\n    \t'user'\t=\u003e 'anemometer',\n    \t'password' =\u003e 'superSecurePass',\n    \t'tables' =\u003e array(\n    \t\t'global_query_review' =\u003e 'fact',\n    \t\t'global_query_review_history' =\u003e 'dimension'\n    \t)\n    );\n\nIn addition, the \"explain\" plugin is enabled by default in the current release and you'll need to setup the username and password it uses to an account that has privileges to explain queries on a given schema on a host.  For example, if you're digesting slow logs that primarily contain queries from the \"world\" database on db.example.com, you'll need to ensure that the user account you put into the following section of the config has the necessary privileges on the \"world\" database on db.example.com.  To do this, scroll down in the sample config to the section containing the plugins configuration and change the 'user' and 'password' parameters to an appropriate account:\n\n    $conf['plugins'] = array(\n            ...\n        'explain'       =\u003e      function ($sample) {\n            $conn['user'] = 'anemometer';\n            $conn['password'] = 'superSecurePass';\n            \n            return $conn;\n        },\n    );\n\n\n\nNow you should be able to navigate to your webserver in a browser and see Box Anemometer in action!\n\n\n### Phpdocs ###\n\nPhpdocs for this tool can be found in the \"docs\" sub-directory of the project.\n\n### Dependencies ###\n\nThis application requires an Apache webserver with PHP 5.5+ and a MySQL database that contains the data aggregated from MySQL slow query logs.\n\n\n## Copyright and License\n\nCopyright 2014 Box, Inc. All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbox%2FAnemometer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbox%2FAnemometer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbox%2FAnemometer/lists"}