Skip to content

Commit

Permalink
Merge branch 'master' into es_client_migration/painless_lab
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 25, 2021
2 parents 125f6b9 + e7e42a4 commit 683f624
Show file tree
Hide file tree
Showing 32 changed files with 373 additions and 167 deletions.
3 changes: 1 addition & 2 deletions docs/management/managing-tags.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Create a tag to assign to your saved objects.
image::images/tags/create-tag.png[Tag creation popin]
. Enter a name and select a color for the new tag.
+
The name can include alphanumeric characters (English letters and digits), `:`, `-`, `_` and the space character,
and cannot be longer than 50 characters.
The name cannot be longer than 50 characters.
. Click *Create tag*.

[float]
Expand Down
79 changes: 38 additions & 41 deletions docs/setup/upgrade/upgrade-migrations.asciidoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[[upgrade-migrations]]
=== Upgrade migrations

Every time {kib} is upgraded it checks to see if all saved objects, such as dashboards, visualizations, and index patterns, are compatible with the new version. If any saved objects need to be updated, then the automatic saved object migration process is kicked off.
Every time {kib} is upgraded it will perform an upgrade migration to ensure that all <<managing-saved-objects,saved objects>> are compatible with the new version.

NOTE: 6.7 includes an https://www.elastic.co/guide/en/kibana/6.7/upgrade-assistant.html[Upgrade Assistant]
to help you prepare for your upgrade to 7.0. To access the assistant, go to *Management > 7.0 Upgrade Assistant*.

WARNING: {kib} 7.12.0 and later uses a new migration process and index naming scheme. Be sure to read the documentation for your version of {kib} before proceeding.

WARNING: The following instructions assumes {kib} is using the default index names. If the `kibana.index` or `xpack.tasks.index` configuration settings were changed these instructions will have to be adapted accordingly.

[float]
Expand All @@ -14,19 +16,35 @@ WARNING: The following instructions assumes {kib} is using the default index nam

Saved objects are stored in two indices:

* `.kibana_N`, or if set, the `kibana.index` configuration setting
* `.kibana_task_manager_N`, or if set, the `xpack.tasks.index` configuration setting
* `.kibana_{kibana_version}_001`, or if the `kibana.index` configuration setting is set `.{kibana.index}_{kibana_version}_001`. E.g. for Kibana v7.12.0 `.kibana_7.12.0_001`.
* `.kibana_task_manager_{kibana_version}_001`, or if the `xpack.tasks.index` configuration setting is set `.{xpack.tasks.index}_{kibana_version}_001` E.g. for Kibana v7.12.0 `.kibana_task_manager_7.12.0_001`.

For each of these indices, `N` is a number that increments every time {kib} runs an upgrade migration on that index. The index aliases `.kibana` and `.kibana_task_manager` point to the most up-to-date index.
The index aliases `.kibana` and `.kibana_task_manager` will always point to the most up-to-date version indices.

The first time a newer {kib} starts, it will first perform an upgrade migration before starting plugins or serving HTTP traffic. To prevent losing acknowledged writes old nodes should be shutdown before starting the upgrade. To reduce the likelihood of old nodes losing acknowledged writes, {kib} 7.12.0 and later will add a write block to the outdated index. Table 1 lists the saved objects indices used by previous versions of {kib}.

.Saved object indices and aliases per {kib} version
[options="header"]
[cols="a,a,a"]
|=======================
|Upgrading from version | Outdated index (alias) | Upgraded index (alias)
| 6.0.0 through 6.4.x | `.kibana` 1.3+^.^| `.kibana_7.12.0_001`
(`.kibana` alias)

`.kibana_task_manager_7.12.0_001` (`.kibana_task_manager` alias)
| 6.5.0 through 7.3.x | `.kibana_N` (`.kibana` alias)
| 7.4.0 through 7.11.x
| `.kibana_N` (`.kibana` alias)

While {kib} is starting up and before serving any HTTP traffic, it checks to see if any internal mapping changes or data transformations for existing saved objects are required.
`.kibana_task_manager_N` (`.kibana_task_manager` alias)
|=======================

When changes are necessary, a new migration is started. To ensure that only one {kib} instance performs the migration, each instance will attempt to obtain a migration lock by creating a new `.kibana_N+1` index. The instance that succeeds in creating the index will then read batches of documents from the existing index, migrate them, and write them to the new index. Once the objects are migrated, the lock is released by pointing the `.kibana` index alias the new upgraded `.kibana_N+1` index.
==== Upgrading multiple {kib} instances
When upgrading several {kib} instances connected to the same {es} cluster, ensure that all outdated instances are shutdown before starting the upgrade.

Instances that failed to acquire a lock will log `Another Kibana instance appears to be migrating the index. Waiting for that migration to complete`. The instance will then wait until `.kibana` points to an upgraded index before starting up and serving HTTP traffic.
Kibana does not support rolling upgrades. However, once outdated instances are shutdown, all upgraded instances can be started in parallel in which case all instances will participate in the upgrade migration in parallel.

NOTE: Prior to 6.5.0, saved objects were stored directly in an index named `.kibana`. After upgrading to version 6.5+, {kib} will migrate this index into `.kibana_N` and set `.kibana` up as an index alias. +
Prior to 7.4.0, task manager tasks were stored directly in an index name `.kibana_task_manager`. After upgrading to version 7.4+, {kib} will migrate this index into `.kibana_task_manager_N` and set `.kibana_task_manager` up as an index alias.
For large deployments with more than 10 {kib} instances and more than 10 000 saved objects, the upgrade downtime can be reduced by bringing up a single {kib} instance and waiting for it to complete the upgrade migration before bringing up the remaining instances.

[float]
[[preventing-migration-failures]]
Expand Down Expand Up @@ -54,50 +72,31 @@ Problems with your {es} cluster can prevent {kib} upgrades from succeeding. Ensu
* a "green" cluster status

[float]
===== Running different versions of {kib} connected to the same {es} index
Kibana does not support rolling upgrades. Stop all {kib} instances before starting a newer version to prevent upgrade failures and data loss.
===== Different versions of {kib} connected to the same {es} index
When different versions of {kib} are attempting an upgrade migration in parallel this can lead to migration failures. Ensure that all {kib} instances are running the same version, configuration and plugins.

[float]
===== Incompatible `xpack.tasks.index` configuration setting
For {kib} < 7.5.1, if the task manager index is set to `.tasks` with the configuration setting `xpack.tasks.index: ".tasks"`, upgrade migrations will fail. {kib} 7.5.1 and later prevents this by refusing to start with an incompatible configuration setting.
For {kib} versions prior to 7.5.1, if the task manager index is set to `.tasks` with the configuration setting `xpack.tasks.index: ".tasks"`, upgrade migrations will fail. {kib} 7.5.1 and later prevents this by refusing to start with an incompatible configuration setting.

[float]
[[resolve-migrations-failures]]
==== Resolving migration failures

If {kib} terminates unexpectedly while migrating a saved object index, manual intervention is required before {kib} will attempt to perform the migration again. Follow the advice in (preventing migration failures)[preventing-migration-failures] before retrying a migration upgrade.

As mentioned above, {kib} will create a migration lock for each index that requires a migration by creating a new `.kibana_N+1` index. For example: if the `.kibana_task_manager` alias is pointing to `.kibana_task_manager_5` then the first {kib} that succeeds in creating `.kibana_task_manager_6` will obtain the lock to start migrations.

However, if the instance that obtained the lock fails to migrate the index, all other {kib} instances will be blocked from performing this migration. This includes the instance that originally obtained the lock, it will be blocked from retrying the migration even when restarted.

[float]
===== Retry a migration by restoring a backup snapshot:

1. Before proceeding ensure that you have a recent and successful backup snapshot of all `.kibana*` indices.
2. Shutdown all {kib} instances to be 100% sure that there are no instances currently performing a migration.
3. Delete all saved object indices with `DELETE /.kibana*`
4. Restore the `.kibana* indices and their aliases from the backup snapshot. See {es} {ref}/modules-snapshots.html[snapshots]
5. Start up all {kib} instances to retry the upgrade migration.

[float]
===== (Not recommended) Retry a migration without a backup snapshot:
If {kib} terminates unexpectedly while migrating a saved object index it will automatically attempt to perform the migration again once the process has restarted. Do not delete any saved objects indices to attempt to fix a failed migration. Unlike previous versions, {kib} version 7.12.0 and later does not require deleting any indices to release a failed migration lock.

1. Shutdown all {kib} instances to be 100% sure that there are no instances currently performing a migration.
2. Identify any migration locks by comparing the output of `GET /_cat/aliases` and `GET /_cat/indices`. If e.g. `.kibana` is pointing to `.kibana_4` and there is a `.kibana_5` index, the `.kibana_5` index will act like a migration lock blocking further attempts. Be sure to check both the `.kibana` and `.kibana_task_manager` aliases and their indices.
3. Remove any migration locks e.g. `DELETE /.kibana_5`.
4. Start up all {kib} instances.
If upgrade migrations fail repeatedly, follow the advice in (preventing migration failures)[preventing-migration-failures]. Once the root cause for the migration failure has been addressed, {kib} will automatically retry the migration without any further intervention. If you're unable to resolve a failed migration following these steps, please contact support.

[float]
[[upgrade-migrations-rolling-back]]
==== Rolling back to a previous version of {kib}

If you've followed the advice in (preventing migration failures)[preventing-migration-failures] and (resolving migration failures)[resolve-migrations-failures] and {kib} is still not able to upgrade successfully, you might choose to rollback {kib} until you're able to identify the root cause.
If you've followed the advice in (preventing migration failures)[preventing-migration-failures] and (resolving migration failures)[resolve-migrations-failures] and {kib} is still not able to upgrade successfully, you might choose to rollback {kib} until you're able to identify and fix the root cause.

WARNING: Before rolling back {kib}, ensure that the version you wish to rollback to is compatible with your {es} cluster. If the version you're rolling back to is not compatible, you will have to also rollback {es}. +
Any changes made after an upgrade will be lost when rolling back to a previous version.

In order to rollback after a failed upgrade migration, the saved object indices might also have to be rolled back to be compatible with the previous {kibana} version.
In order to rollback after a failed upgrade migration, the saved object indices have to be rolled back to be compatible with the previous {kibana} version.

[float]
===== Rollback by restoring a backup snapshot:
Expand All @@ -111,17 +110,15 @@ In order to rollback after a failed upgrade migration, the saved object indices
[float]
===== (Not recommended) Rollback without a backup snapshot:

WARNING: {kib} does not run a migration for every saved object index on every upgrade. A {kib} version upgrade can cause no migrations, migrate only the `.kibana` or the `.kibana_task_manager` index or both. Carefully read the logs to ensure that you're only deleting indices created by a later version of {kib} to avoid data loss.

1. Shutdown all {kib} instances to be 100% sure that there are no {kib} instances currently performing a migration.
2. Create a backup snapshot of the `.kibana*` indices.
3. Use the logs from the upgraded instances to identify which indices {kib} attempted to upgrade. The server logs will contain an entry like `[savedobjects-service] Creating index .kibana_4.` and/or `[savedobjects-service] Creating index .kibana_task_manager_2.` If no indices were created after upgrading {kib} then no further action is required to perform a rollback, skip ahead to step (5). If you're running multiple {kib} instances, be sure to inspect all instances' logs.
4. Delete each of the indices identified in step (2). e.g. `DELETE /.kibana_task_manager_2`
5. Inspect the output of `GET /_cat/aliases`. If either the `.kibana` and/or `.kibana_task_manager` alias is missing, these will have to be created manually. Find the latest index from the output of `GET /_cat/indices` and create the missing alias to point to the latest index. E.g. if the `.kibana` alias was missing and the latest index is `.kibana_3` create a new alias with `POST /.kibana_3/_aliases/.kibana`.
3. Delete the version specific indices created by the failed upgrade migration. E.g. if you wish to rollback from a failed upgrade to v7.12.0 `DELETE /.kibana_7.12.0_*,.kibana_task_manager_7.12.0_*`
4. Inspect the output of `GET /_cat/aliases`. If either the `.kibana` and/or `.kibana_task_manager` alias is missing, these will have to be created manually. Find the latest index from the output of `GET /_cat/indices` and create the missing alias to point to the latest index. E.g. if the `.kibana` alias was missing and the latest index is `.kibana_3` create a new alias with `POST /.kibana_3/_aliases/.kibana`.
5. Remove the write block from the rollback indices. `PUT /.kibana,.kibana_task_manager/_settings {"index.blocks.write": false}`
6. Start up {kib} on the older version you wish to rollback to.

[float]
[[upgrade-migrations-old-indices]]
==== Handling old `.kibana_N` indices

After migrations have completed, there will be multiple {kib} indices in {es}: (`.kibana_1`, `.kibana_2`, etc). {kib} only uses the index that the `.kibana` alias points to. The other {kib} indices can be safely deleted, but are left around as a matter of historical record, and to facilitate rolling {kib} back to a previous version.
After migrations have completed, there will be multiple {kib} indices in {es}: (`.kibana_1`, `.kibana_2`, `.kibana_7.12.0` etc). {kib} only uses the index that the `.kibana` and `.kibana_task_manager` alias points to. The other {kib} indices can be safely deleted, but are left around as a matter of historical record, and to facilitate rolling {kib} back to a previous version.
14 changes: 8 additions & 6 deletions docs/setup/upgrade/upgrade-standard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ necessary remediation steps as per those instructions.
[float]
==== Upgrading multiple {kib} instances

WARNING: Kibana does not support rolling upgrades. If you're running multiple {kib} instances, all instances should be stopped before upgrading.
NOTE: Kibana does not support rolling upgrades. If you're running multiple {kib} instances, all instances should be stopped before upgrading.

Different versions of {kib} running against the same {es} index, such as during a rolling upgrade, can cause upgrade migration failures and data loss. This is because acknowledged writes from the older instances could be written into the _old_ index while the migration is in progress. To prevent this from happening ensure that all old {kib} instances are shutdown before starting up instances on a newer version.

The first instance that triggers saved object migrations will run the entire process. Any other instances started up while a migration is running will log a message and then wait until saved object migrations has completed before they start serving HTTP traffic.
Different versions of {kib} running against the same {es} index, such as during a rolling upgrade, can cause data loss. This is because older instances will continue to write saved objects in a different format than the newer instances. To prevent this from happening ensure that all old {kib} instances are shutdown before starting up instances on a newer version.

[float]
==== Upgrade using a `deb` or `rpm` package

. Stop the existing {kib} process using the appropriate command for your
system. If you have multiple {kib} instances connecting to the same {es} cluster ensure that all instances are stopped before proceeding to the next step to avoid data loss.
system. If you have multiple {kib} instances connecting to the same {es}
cluster ensure that all instances are stopped before proceeding to the next
step to avoid data loss.
. Use `rpm` or `dpkg` to install the new package. All files should be placed in
their proper locations and config files should not be overwritten.
+
Expand Down Expand Up @@ -65,5 +65,7 @@ and becomes a new instance in the monitoring data.
. Install the appropriate versions of all your plugins for your new
installation using the `kibana-plugin` script. Check out the
<<kibana-plugins,plugins>> documentation for more information.
. Stop the old {kib} process. If you have multiple {kib} instances connecting to the same {es} cluster ensure that all instances are stopped before proceeding to the next step to avoid data loss.
. Stop the old {kib} process. If you have multiple {kib} instances connecting
to the same {es} cluster ensure that all instances are stopped before
proceeding to the next step to avoid data loss.
. Start the new {kib} process.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
type: TooltipType.VerticalCursor,
};

const xAxisFormatter = getServices().data.fieldFormats.deserialize(
this.props.chartData.yAxisFormat
);

return (
<Chart size="100%">
<Settings
Expand All @@ -169,6 +173,8 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
position={Position.Left}
ticks={5}
title={chartData.yAxisLabel}
integersOnly
tickFormat={(value) => xAxisFormatter.convert(value)}
/>
<Axis
id="discover-histogram-bottom-axis"
Expand Down
22 changes: 11 additions & 11 deletions src/plugins/discover/public/application/angular/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ app.directive('discoverApp', function () {
};
});

function discoverController($element, $route, $scope, $timeout, Promise) {
function discoverController($route, $scope, Promise) {
const { isDefault: isDefaultType } = indexPatternsUtils;
const subscriptions = new Subscription();
const refetch$ = new Subject();
Expand Down Expand Up @@ -725,20 +725,20 @@ function discoverController($element, $route, $scope, $timeout, Promise) {
$route.reload();
};

$scope.onSkipBottomButtonClick = function () {
$scope.onSkipBottomButtonClick = async () => {
// show all the Rows
$scope.minimumVisibleRows = $scope.hits;

// delay scrolling to after the rows have been rendered
const bottomMarker = $element.find('#discoverBottomMarker');
$timeout(() => {
bottomMarker.focus();
// The anchor tag is not technically empty (it's a hack to make Safari scroll)
// so the browser will show a highlight: remove the focus once scrolled
$timeout(() => {
bottomMarker.blur();
}, 0);
}, 0);
const bottomMarker = document.getElementById('discoverBottomMarker');
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

while ($scope.rows.length !== document.getElementsByClassName('kbnDocTable__row').length) {
await wait(50);
}
bottomMarker.focus();
await wait(50);
bottomMarker.blur();
};

$scope.newQuery = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface Chart {
}>;
xAxisOrderedValues: number[];
xAxisFormat: Dimension['format'];
yAxisFormat: Dimension['format'];
xAxisLabel: Column['name'];
yAxisLabel?: Column['name'];
ordered: Ordered;
Expand All @@ -76,7 +77,7 @@ export const buildPointSeriesData = (table: Table, dimensions: Dimensions) => {
chart.xAxisOrderedValues = uniq(table.rows.map((r) => r[xAccessor] as number));
chart.xAxisFormat = x.format;
chart.xAxisLabel = table.columns[x.accessor].name;

chart.yAxisFormat = y.format;
const { intervalESUnit, intervalESValue, interval, bounds } = x.params;
chart.ordered = {
date: true,
Expand Down
Loading

0 comments on commit 683f624

Please sign in to comment.