{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/beats/pulls/comments/124666356","pull_request_review_id":46978831,"id":124666356,"diff_hunk":"@@ -0,0 +1,141 @@\n+package kibana\n+\n+import (\n+\t\"crypto/tls\"\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"io/ioutil\"\n+\t\"net/http\"\n+\t\"net/url\"\n+\t\"path\"\n+\n+\t\"github.com/elastic/beats/libbeat/common\"\n+\t\"github.com/elastic/beats/libbeat/logp\"\n+)\n+\n+type Connection struct {\n+\tURL     string\n+\tHeaders map[string]string\n+\n+\thttp    *http.Client\n+\tversion string\n+}\n+\n+type Client struct {\n+\tConnection\n+}\n+\n+func addPath(_url, _path string) (string, error) {\n+\n+\tu, err := url.Parse(_url)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\tu.Path = path.Join(u.Path, _path)\n+\treturn u.String(), nil\n+}\n+\n+func NewKibanaClient(cfg *common.Config) (*Client, error) {\n+\n+\tconfig := defaultKibanaConfig\n+\tif err := cfg.Unpack(&config); err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tkibanaURL, err := common.MakeURL(config.Protocol, config.Path, config.Host, 5601)\n+\tif err != nil {\n+\t\tlogp.Err(\"Invalid host param set: %s, Error: %v\", config.Host, err)\n+\t\treturn nil, fmt.Errorf(\"invalid Kibana host: %v\", err)\n+\t}\n+\n+\tlogp.Debug(\"kibana\", \"Kibana url: %s\", kibanaURL)\n+\n+\tclient := &Client{\n+\n+\t\tConnection: Connection{\n+\t\t\tURL: kibanaURL,\n+\t\t\thttp: &http.Client{\n+\t\t\t\tTransport: &http.Transport{\n+\t\t\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // ignore expired SSL certificates","path":"libbeat/setup/kibana/client.go","position":60,"original_position":60,"commit_id":"3363bac549669325b6687857c25febdee5ab3451","original_commit_id":"3363bac549669325b6687857c25febdee5ab3451","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars1.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"body":"This is something that we need to address in the next PR.","created_at":"2017-06-28T21:52:13Z","updated_at":"2017-06-28T21:52:13Z","html_url":"https://github.com/elastic/beats/pull/4413#discussion_r124666356","pull_request_url":"https://api.github.com/repos/elastic/beats/pulls/4413","_links":{"self":{"href":"https://api.github.com/repos/elastic/beats/pulls/comments/124666356"},"html":{"href":"https://github.com/elastic/beats/pull/4413#discussion_r124666356"},"pull_request":{"href":"https://api.github.com/repos/elastic/beats/pulls/4413"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/beats/pulls/4413","id":122901495,"html_url":"https://github.com/elastic/beats/pull/4413","diff_url":"https://github.com/elastic/beats/pull/4413.diff","patch_url":"https://github.com/elastic/beats/pull/4413.patch","issue_url":"https://api.github.com/repos/elastic/beats/issues/4413","number":4413,"state":"open","locked":false,"title":"Use import/export API for loading dashboards and index pattern","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars1.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"body":"This is trying to implement https://github.com/elastic/beats/issues/4409. \r\n\r\nThe Beats 6.x dashboards are different than the Beats 5.x dashboards and are not compatible. Thanks to the Kibana API, we can have a json file for each module instead of multiple json files (for dashboards, visualizations, searches, etc). Thus, the way to import/export dashboards differs from the Kibana version that should be equal to the Elasticsearch version.\r\n\r\nThe json file containing the index-pattern contain as `version` the Beat version, and the dashboards contain as `version` the Kibana version that exported the dashboards.\r\n\r\nIf Kibana version is 5.x and older: \r\n- The dashboards should be imported/exported directly from Elasticsearch, and it works only if Elasticsearch is set as output\r\n- All the Beats dashboards are moved to  the `_meta/kibana/5.x` directory \r\n\r\nIf Kibana version is 6.x and greater:\r\n- The dashboards should be imported/exported via the Kibana API, so the user needs to configure the kibana url under the `setup.kibana*` settings.\r\n- All the Beats 6.x dashboards should be added to the `_meta/kibana/default` directory for each Beat module.\r\n\r\nIn order to make use of the import/export API the following changes are needed:\r\n- [x] move all the old dashboards, search, visualizations, index-pattern to `_meta/kibana/5.x` directory\r\nand create a new directory under `_meta/kibana/default` for the new dashboards and index-pattern that are importable via the Kibana API\r\n- [x] update generate_index_pattern to generate the index-pattern for 5.x and >= 6.x versions\r\n- [x] use the Kibana API to load the dashboards and the index pattern for Kibana >= 6\r\n- [x] update import_dashboards script\r\n- [x] update `make update`\r\n- [x] update integration tests\r\n\r\nNote: The older dashboards are moved to the `_meta/kibana/5.x` directory only for Metricbeat for now.\r\n","created_at":"2017-05-29T14:05:24Z","updated_at":"2017-06-28T21:52:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87f29f66102744363136d1c91b2106571197d2c7","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/beats/pulls/4413/commits","review_comments_url":"https://api.github.com/repos/elastic/beats/pulls/4413/comments","review_comment_url":"https://api.github.com/repos/elastic/beats/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/beats/issues/4413/comments","statuses_url":"https://api.github.com/repos/elastic/beats/statuses/3363bac549669325b6687857c25febdee5ab3451","head":{"label":"monicasarbu:use_import_export_api","ref":"use_import_export_api","sha":"3363bac549669325b6687857c25febdee5ab3451","user":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars1.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"repo":{"id":47255032,"name":"beats","full_name":"monicasarbu/beats","owner":{"login":"monicasarbu","id":11757159,"avatar_url":"https://avatars1.githubusercontent.com/u/11757159?v=3","gravatar_id":"","url":"https://api.github.com/users/monicasarbu","html_url":"https://github.com/monicasarbu","followers_url":"https://api.github.com/users/monicasarbu/followers","following_url":"https://api.github.com/users/monicasarbu/following{/other_user}","gists_url":"https://api.github.com/users/monicasarbu/gists{/gist_id}","starred_url":"https://api.github.com/users/monicasarbu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monicasarbu/subscriptions","organizations_url":"https://api.github.com/users/monicasarbu/orgs","repos_url":"https://api.github.com/users/monicasarbu/repos","events_url":"https://api.github.com/users/monicasarbu/events{/privacy}","received_events_url":"https://api.github.com/users/monicasarbu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monicasarbu/beats","description":"Moved here: https://github.com/elastic/beats","fork":true,"url":"https://api.github.com/repos/monicasarbu/beats","forks_url":"https://api.github.com/repos/monicasarbu/beats/forks","keys_url":"https://api.github.com/repos/monicasarbu/beats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monicasarbu/beats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monicasarbu/beats/teams","hooks_url":"https://api.github.com/repos/monicasarbu/beats/hooks","issue_events_url":"https://api.github.com/repos/monicasarbu/beats/issues/events{/number}","events_url":"https://api.github.com/repos/monicasarbu/beats/events","assignees_url":"https://api.github.com/repos/monicasarbu/beats/assignees{/user}","branches_url":"https://api.github.com/repos/monicasarbu/beats/branches{/branch}","tags_url":"https://api.github.com/repos/monicasarbu/beats/tags","blobs_url":"https://api.github.com/repos/monicasarbu/beats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monicasarbu/beats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monicasarbu/beats/git/refs{/sha}","trees_url":"https://api.github.com/repos/monicasarbu/beats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monicasarbu/beats/statuses/{sha}","languages_url":"https://api.github.com/repos/monicasarbu/beats/languages","stargazers_url":"https://api.github.com/repos/monicasarbu/beats/stargazers","contributors_url":"https://api.github.com/repos/monicasarbu/beats/contributors","subscribers_url":"https://api.github.com/repos/monicasarbu/beats/subscribers","subscription_url":"https://api.github.com/repos/monicasarbu/beats/subscription","commits_url":"https://api.github.com/repos/monicasarbu/beats/commits{/sha}","git_commits_url":"https://api.github.com/repos/monicasarbu/beats/git/commits{/sha}","comments_url":"https://api.github.com/repos/monicasarbu/beats/comments{/number}","issue_comment_url":"https://api.github.com/repos/monicasarbu/beats/issues/comments{/number}","contents_url":"https://api.github.com/repos/monicasarbu/beats/contents/{+path}","compare_url":"https://api.github.com/repos/monicasarbu/beats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monicasarbu/beats/merges","archive_url":"https://api.github.com/repos/monicasarbu/beats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monicasarbu/beats/downloads","issues_url":"https://api.github.com/repos/monicasarbu/beats/issues{/number}","pulls_url":"https://api.github.com/repos/monicasarbu/beats/pulls{/number}","milestones_url":"https://api.github.com/repos/monicasarbu/beats/milestones{/number}","notifications_url":"https://api.github.com/repos/monicasarbu/beats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monicasarbu/beats/labels{/name}","releases_url":"https://api.github.com/repos/monicasarbu/beats/releases{/id}","deployments_url":"https://api.github.com/repos/monicasarbu/beats/deployments","created_at":"2015-12-02T10:50:02Z","updated_at":"2015-12-02T10:50:07Z","pushed_at":"2017-06-28T12:55:17Z","git_url":"git://github.com/monicasarbu/beats.git","ssh_url":"git@github.com:monicasarbu/beats.git","clone_url":"https://github.com/monicasarbu/beats.git","svn_url":"https://github.com/monicasarbu/beats","homepage":"","size":54978,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:master","ref":"master","sha":"84c0be20396613623f6d0fb589ff8a9c7915c259","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars3.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":16554739,"name":"beats","full_name":"elastic/beats","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars3.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/beats","description":":tropical_fish: Beats - Lightweight shippers for Elasticsearch & Logstash ","fork":false,"url":"https://api.github.com/repos/elastic/beats","forks_url":"https://api.github.com/repos/elastic/beats/forks","keys_url":"https://api.github.com/repos/elastic/beats/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/beats/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/beats/teams","hooks_url":"https://api.github.com/repos/elastic/beats/hooks","issue_events_url":"https://api.github.com/repos/elastic/beats/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/beats/events","assignees_url":"https://api.github.com/repos/elastic/beats/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/beats/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/beats/tags","blobs_url":"https://api.github.com/repos/elastic/beats/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/beats/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/beats/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/beats/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/beats/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/beats/languages","stargazers_url":"https://api.github.com/repos/elastic/beats/stargazers","contributors_url":"https://api.github.com/repos/elastic/beats/contributors","subscribers_url":"https://api.github.com/repos/elastic/beats/subscribers","subscription_url":"https://api.github.com/repos/elastic/beats/subscription","commits_url":"https://api.github.com/repos/elastic/beats/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/beats/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/beats/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/beats/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/beats/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/beats/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/beats/merges","archive_url":"https://api.github.com/repos/elastic/beats/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/beats/downloads","issues_url":"https://api.github.com/repos/elastic/beats/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/beats/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/beats/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/beats/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/beats/labels{/name}","releases_url":"https://api.github.com/repos/elastic/beats/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/beats/deployments","created_at":"2014-02-05T19:01:02Z","updated_at":"2017-06-28T16:46:22Z","pushed_at":"2017-06-28T20:25:07Z","git_url":"git://github.com/elastic/beats.git","ssh_url":"git@github.com:elastic/beats.git","clone_url":"https://github.com/elastic/beats.git","svn_url":"https://github.com/elastic/beats","homepage":"https://www.elastic.co/products/beats","size":56055,"stargazers_count":4135,"watchers_count":4135,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1033,"mirror_url":null,"open_issues_count":460,"forks":1033,"open_issues":460,"watchers":4135,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/beats/pulls/4413"},"html":{"href":"https://github.com/elastic/beats/pull/4413"},"issue":{"href":"https://api.github.com/repos/elastic/beats/issues/4413"},"comments":{"href":"https://api.github.com/repos/elastic/beats/issues/4413/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/beats/pulls/4413/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/beats/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/beats/pulls/4413/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/beats/statuses/3363bac549669325b6687857c25febdee5ab3451"}}}}
{"actor":{"display_login":"monicasarbu"}}