-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Beats Management] Install Beats index template on plugin init (#19072)
* Install Beats index template on plugin init * Adding missing files
- Loading branch information
1 parent
49cd7e3
commit 733c85c
Showing
6 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/beats/server/lib/client/call_with_internal_user_factory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { once } from 'lodash'; | ||
|
||
const callWithInternalUser = once((server) => { | ||
const { callWithInternalUser } = server.plugins.elasticsearch.getCluster('admin'); | ||
return callWithInternalUser; | ||
}); | ||
|
||
export const callWithInternalUserFactory = (server) => { | ||
return callWithInternalUser(server); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { callWithInternalUserFactory } from './call_with_internal_user_factory'; |
84 changes: 84 additions & 0 deletions
84
x-pack/plugins/beats/server/lib/index_template/beats_template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"index_patterns": [ | ||
".management-beats" | ||
], | ||
"version": 65000, | ||
"settings": { | ||
"index": { | ||
"number_of_shards": 1, | ||
"auto_expand_replicas": "0-1", | ||
"codec": "best_compression" | ||
} | ||
}, | ||
"mappings": { | ||
"_doc": { | ||
"dynamic": "strict", | ||
"properties": { | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"enrollment_token": { | ||
"properties": { | ||
"token": { | ||
"type": "keyword" | ||
}, | ||
"expires_on": { | ||
"type": "date" | ||
} | ||
} | ||
}, | ||
"configuration_block": { | ||
"properties": { | ||
"tag": { | ||
"type": "keyword" | ||
}, | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"block_yml": { | ||
"type": "text" | ||
} | ||
} | ||
}, | ||
"beat": { | ||
"properties": { | ||
"id": { | ||
"type": "keyword" | ||
}, | ||
"enrollment_token": { | ||
"type": "keyword" | ||
}, | ||
"access_token": { | ||
"type": "keyword" | ||
}, | ||
"verified_on": { | ||
"type": "date" | ||
}, | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"host_ip": { | ||
"type": "keyword" | ||
}, | ||
"host_name": { | ||
"type": "keyword" | ||
}, | ||
"ephemeral_id": { | ||
"type": "keyword" | ||
}, | ||
"local_configuration_yml": { | ||
"type": "text" | ||
}, | ||
"central_configuration_yml": { | ||
"type": "text" | ||
}, | ||
"metadata": { | ||
"dynamic": "true", | ||
"type": "object" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { installIndexTemplate } from './install_index_template'; |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/beats/server/lib/index_template/install_index_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import beatsIndexTemplate from './beats_template'; | ||
import { callWithInternalUserFactory } from '../client'; | ||
|
||
const TEMPLATE_NAME = 'beats-template'; | ||
|
||
export function installIndexTemplate(server) { | ||
const callWithInternalUser = callWithInternalUserFactory(server); | ||
return callWithInternalUser('indices.putTemplate', { | ||
name: TEMPLATE_NAME, | ||
body: beatsIndexTemplate | ||
}); | ||
} |