Skip to content

Commit

Permalink
Ensuring the data range selection works when linking out to kibana
Browse files Browse the repository at this point in the history
  • Loading branch information
codyrancher committed Jan 24, 2022
1 parent 074f034 commit 2e8d477
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 23 deletions.
1 change: 0 additions & 1 deletion components/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export default {
},
toggle() {
console.log('toggle')
this.$set(this, 'maximized', !this.maximized);
}
},
Expand Down
35 changes: 21 additions & 14 deletions components/formatter/KibanaLink.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
const UTC_FORMAT = 'YYYY-MM-DDTHH:mm:ss.SSS[Z]';
export default {
props: {
value: {
Expand All @@ -17,23 +19,28 @@ export default {
computed: {
query() {
console.log('ppp', this.options);
const fromTo = this.options.fromTo;
const fromDelta = Math.floor(fromTo.to.diff(fromTo.from, 'hours', true));
switch (this.options.type) {
case 'pod':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-${fromDelta}h,to:now))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes.pod_name,negate:!f,params:(query:${this.value}),type:phrase),query:(match_phrase:(kubernetes.pod_name:${this.value})))),interval:auto,query:(language:kuery,query:''),sort:!())`
case 'control-plane':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-${fromDelta}h,to:now))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:is_control_plane_log,negate:!f,params:(query:!t),type:phrase),query:(match_phrase:(is_control_plane_log:!t))),('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes_component,negate:!f,params:(query:${this.value}),type:phrase),query:(match_phrase:(kubernetes_component:${this.value})))),interval:auto,query:(language:kuery,query:''),sort:!())`;
case 'namespace':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-${fromDelta}h,to:now))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes.namespace_name,negate:!f,params:(query:${this.value}),type:phrase),query:(match_phrase:(kubernetes.namespace_name:${this.value})))),interval:auto,query:(language:kuery,query:''),sort:!())`;
case 'workload':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-${fromDelta}h,to:now))&_a=(columns:!(_source),filters:!(),interval:auto,query:(language:kuery,query:"${this.value}"),sort:!())`;
default:
return '';
case 'pod':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'${ this.from }',to:'${ this.to }'))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes.pod_name,negate:!f,params:(query:${ this.value }),type:phrase),query:(match_phrase:(kubernetes.pod_name:${ this.value })))),interval:auto,query:(language:kuery,query:''),sort:!())`;
case 'control-plane':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'${ this.from }',to:'${ this.to }'))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:is_control_plane_log,negate:!f,params:(query:!t),type:phrase),query:(match_phrase:(is_control_plane_log:!t))),('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes_component,negate:!f,params:(query:${ this.value }),type:phrase),query:(match_phrase:(kubernetes_component:${ this.value })))),interval:auto,query:(language:kuery,query:''),sort:!())`;
case 'namespace':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'${ this.from }',to:'${ this.to }'))&_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,key:kubernetes.namespace_name,negate:!f,params:(query:${ this.value }),type:phrase),query:(match_phrase:(kubernetes.namespace_name:${ this.value })))),interval:auto,query:(language:kuery,query:''),sort:!())`;
case 'workload':
return `_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:'${ this.from }',to:'${ this.to }'))&_a=(columns:!(_source),filters:!(),interval:auto,query:(language:kuery,query:"${ this.value }"),sort:!())`;
default:
return '';
}
},
from() {
return this.options.fromTo.from.utc().format(UTC_FORMAT);
},
to() {
return this.options.fromTo.to.utc().format(UTC_FORMAT);
},
url() {
const hostname = window.location.hostname;
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ module.exports = {
'~/plugins/directives',
'~/plugins/transitions',
'~/plugins/calendar',
'~/plugins/day',
{ src: '~plugins/vue-js-modal' },
{ src: '~/plugins/js-yaml', ssr: false },
{ src: '~/plugins/resize', ssr: false },
Expand Down
4 changes: 4 additions & 0 deletions plugins/day.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import day from 'dayjs';
import utc from 'dayjs/plugin/utc';

day.extend(utc);
2 changes: 1 addition & 1 deletion product/opni/components/ControlPlaneBreakdownDetail.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import SortableTable from '@/components/SortableTable';
import { SIMPLE_NAME, ANOMALY, NORMAL, SUSPICIOUS } from '@/config/table-headers';
import { ANOMALY, NORMAL, SUSPICIOUS } from '@/config/table-headers';
import LogsDrawer from './LogsDrawer';
import { getControlPlaneLogs } from '~/product/opni/utils/requests';
Expand Down
2 changes: 1 addition & 1 deletion product/opni/components/NamespaceBreakdownDetail.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import SortableTable from '@/components/SortableTable';
import { SIMPLE_NAME, ANOMALY, NORMAL, SUSPICIOUS } from '@/config/table-headers';
import { ANOMALY, NORMAL, SUSPICIOUS } from '@/config/table-headers';
import LogsDrawer from './LogsDrawer';
import { getNamespaceLogs } from '~/product/opni/utils/requests';
Expand Down
9 changes: 3 additions & 6 deletions product/opni/components/WorkloadBreakdownDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ export default {
return {
headers: [
{
name: 'Name',
label: 'Name',
value: 'breakdown.name',
sort: `breakdown.name`,
formatter: 'KibanaLink',
formatterOpts: { options: { fromTo: this.fromTo, type: 'workload' } },
...SIMPLE_NAME,
width: null,
value: 'breakdown.name'
},
BREAKDOWN_RESOURCE,
ANOMALY(this.select, undefined, 'breakdown.insights.anomalyFormatted', 'breakdown.insights.anomaly'),
Expand Down

0 comments on commit 2e8d477

Please sign in to comment.