Files
openobserve/web/src/plugins/logs/FunctionSelector.vue
T
09abc46689 fix: fixed searcharound and parsed unparsed sql (#8240)
### **PR Type**
Enhancement, Bug fix, Tests


___

### **Description**
- Introduce streaming search composable

- Add WebSocket/HTTP streaming orchestration

- Implement histogram streaming and pagination

- Enhance multi-stream SQL handling


___

### Diagram Walkthrough


```mermaid
flowchart LR
  SB["useSearchBar: query orchestration"] -- "builds request / sets method" --> SS["useSearchStream: streaming engine"]
  SS -- "WS/HTTP streaming" --> SWS["useSearchWebSocket/useStreamingSearch"]
  SS -- "histogram logic" --> HG["useHistogram"]
  SS -- "fields/columns" --> SF["useStreamFields"]
  SB -- "partitions/page-count (HTTP)" --> PAG["usePagination"]
  SS -- "state + URL updates" --> ST["searchState/logsUtils"]
  SB -- "functions/actions" --> ACT["useFunctions/useActions"]
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>25
files</summary><table>
<tr>
<td><strong>useSearchStream.ts</strong><dd><code>New streaming search
composable with WS/HTTP handlers</code>&nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-0b7e910195d1ec4b1301973bd2f4193e1e23442103f69a9fbd189d3f78547014">+2171/-0</a></td>

</tr>

<tr>
<td><strong>useSearchBar.ts</strong><dd><code>Orchestrate search,
partitions, cancel, and method selection</code></dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-489bda221a164cbee8d66aaf178acb4e0d8a860dbdf39558804fc32c9efd71e8">+1351/-0</a></td>

</tr>

<tr>
<td><strong>logs.ts</strong><dd><code>Add logs-related TypeScript
interfaces</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-637857fa918f47ffb02ebfc8a35b124001ef4f65fd180c467f0f153382d2dc76">+89/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>index.ts</strong><dd><code>Export logs interfaces from
barrel file</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-108f7ecc761a491fd64530704bf44f21473916e1d2ae495376dc996206104088">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>useStreamFields.ts</strong><dd><code>Stream fields
extraction and grid columns utilities</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-14f575947dcdd7aa0e05646be62ed15b4651a25154f679a3a08ce1bc2252acec">+1105/-0</a></td>

</tr>

<tr>
<td><strong>usePagination.ts</strong><dd><code>Partition-aware
pagination and data fetching helpers</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-74277c3b3b1f9b684913ac55ce19c72b29b477021b0ff32af44f8191b17f24a1">+869/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>logsUtils.ts</strong><dd><code>SQL parsing helpers, query
transforms, and tracing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-c8550678e2f4da95dd54d03d9893f6bfff2061460c4a2f2c324fdd3b1d392a52">+735/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>useHistogram.ts</strong><dd><code>Histogram generation,
skeleton, and multi-stream support</code>&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-4d467d6778569f239f96f3af9ec30214aa8b029892bf40a0aa038dfbb73eca6e">+609/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>searchState.ts</strong><dd><code>Centralized reactive logs
search state</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-c0ac4f131ad64edd2ed811e183bb570be2f38d58c9ed958d093457a51280ec34">+412/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>constants.ts</strong><dd><code>Add logs module
constants</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-70282396b9397710380ad150da4428630b1b6e4a41b40d206d43cd2eb7f3b653">+279/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>searchAround.ts</strong><dd><code>Search-around utilities
for contextual queries</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-0090387d8955180e33b700e25de27dd8356a3656449a8bae3442ab476dc50494">+269/-0</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>logsVisualization.ts</strong><dd><code>Visualization helpers
for logs/histogram</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-5913cd8ca0e98529736da0801f08bf2cd1d861ad01442fbf628d1925ed4c87a1">+46/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>useLogs.ts</strong><dd><code>Integrate new composables and
streaming flow</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-1040f61354f92711e0e77ed4e9bfa15586d45a94c7e2ab06cc37372068030e7b">+598/-7006</a></td>

</tr>

<tr>
<td><strong>useStreams.ts</strong><dd><code>Stream fetching support for
multi-stream scenarios</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-a083369344f022cdf8d4f536719179b1d920369e33e2e26234e70dd36d151a7c">+50/-42</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>useSuggestions.ts</strong><dd><code>Suggestions aligned with
SQL/streams changes</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-6d2ecd5b90970ea8c8f5d35c5928a2cf8bf0ed14af700db0202759158bfbbf9d">+56/-25</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>Index.vue</strong><dd><code>Wire UI to streaming search
lifecycle</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-0323c3da69b369843c5d72bf4df5b00ca6b5147192a213baf331659ecf92af62">+104/-61</a></td>

</tr>

<tr>
<td><strong>SearchBar.vue</strong><dd><code>UI updates for new search
orchestration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-81893de4edf186b0556f610acb280c87baa2ffe67d3b48a60a866094c7635baf">+41/-27</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>SearchHistory.vue</strong><dd><code>Adjust to new state and
tracing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-9dd167bd5e272b2057f53c16b905047eec00655a3552daad240a964d67a6f56d">+6/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>SearchResult.vue</strong><dd><code>Display streamed hits,
histogram, pagination</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-5e65533aa4754bb6d0074fda18ffc1ecacded3b9ca6bc28a161c3f6b12f20195">+14/-8</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>IndexList.vue</strong><dd><code>Support streaming responses
and errors</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-08f058f883b659e713e606991a7ea37ae1ff016b7cccef970489ab5840dc3d09">+14/-10</a>&nbsp;
</td>

</tr>

<tr>
<td><strong>DetailTable.vue</strong><dd><code>Column updates based on
streamed fields</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-80552b5d25fa6cef9fbbe430b1865d761c4b132284c2d2175afceea8cbabc8c7">+5/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>JsonPreview.vue</strong><dd><code>Handle streamed hit
rendering</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-3985073134d35ff074742944b114d0905524038b42e6d2ac887fef2c8436fb16">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>SearchSchedulersList.vue</strong><dd><code>Align scheduler
with new search flow</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-0c0a4097c53f07712d35562b1336602bf24faddedab77a9f5717f5582dcac2f1">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>TransformSelector.vue</strong><dd><code>Transform selection
wired to query transforms</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-0037d8dd9cfbacc26309b26e98ae953e7ccbd0891ac2fd01c6314ebd7eed9d2c">+5/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>FunctionSelector.vue</strong><dd><code>Functions integration
with streaming search</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-11d9577516700b94b5f3325e77214d0d886473e690db8c9ea981613c9fb89b68">+2/-2</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Miscellaneous</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>useLogs_original.ts.original</strong><dd><code>Preserve
original composable for reference</code>&nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8240/files#diff-00d4815f6d83c48def131ba94f5131e6cae436bf949cc8abf9b8beacdb0aaf7f">+7033/-0</a></td>

</tr>
</table></details></td></tr></tr></tbody></table>

</details>

___

---------

Co-authored-by: omkark06 <omkar@zinclabs.io>
Co-authored-by: Sai Nikhil <nikhil@openobserve.ai>
2025-09-16 14:51:02 +05:30

153 lines
4.1 KiB
Vue

<!-- Copyright 2023 OpenObserve Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<template>
<q-toggle
data-test="logs-search-bar-show-query-toggle-btn"
v-model="searchObj.meta.showTransformEditor"
:icon="functionToggleIcon"
title="Toggle Function Editor"
class="float-left"
size="32px"
/>
<q-btn-group
class="no-outline q-pa-none no-border float-left q-mr-xs"
:disable="!searchObj.meta.showTransformEditor"
>
<q-btn-dropdown
data-test="logs-search-bar-function-dropdown"
v-model="functionModel"
size="12px"
icon="save"
:icon-right="iconRight"
:title="t('search.functionPlaceholder')"
split
class="no-outline saved-views-dropdown no-border btn-function"
@click="fnSavedFunctionDialog"
>
<q-list data-test="logs-search-saved-function-list">
<!-- Search Input -->
<div>
<q-input
v-model="searchTerm"
dense
filled
borderless
clearable
debounce="300"
:placeholder="t('search.searchSavedFunction')"
data-test="function-search-input"
>
<template #prepend>
<q-icon name="search" />
</template>
</q-input>
</div>
<div v-if="filteredFunctionOptions.length">
<q-item
class="tw-border-b saved-view-item"
clickable
v-for="(item, i) in filteredFunctionOptions"
:key="'saved-view-' + i"
v-close-popup
>
<q-item-section
@click.stop="applyFunction(item, true)"
v-close-popup
>
<q-item-label>{{ item.name }}</q-item-label>
</q-item-section>
</q-item>
</div>
<div v-else>
<q-item>
<q-item-section>
<q-item-label>{{
t("search.savedFunctionNotFound")
}}</q-item-label>
</q-item-section>
</q-item>
</div>
</q-list>
</q-btn-dropdown>
</q-btn-group>
</template>
<script setup lang="ts">
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { searchState } from "@/composables/useLogs/searchState";
import { getImageURL } from "@/utils/zincutils";
import { useStore } from "vuex";
const props = defineProps<{
functionOptions: { name: string; function: string }[];
}>();
const emit = defineEmits(["select:function", "save:function"]);
const { t } = useI18n();
const { searchObj } = searchState();
const store = useStore();
const functionToggleIcon = computed(() => {
return (
"img:" +
getImageURL(
searchObj.meta.showTransformEditor
? "images/common/function_dark.svg"
: "images/common/function.svg",
)
);
});
const iconRight = computed(() => {
return (
"img:" +
getImageURL(
store.state.theme === "dark"
? "images/common/function_dark.svg"
: "images/common/function.svg",
)
);
});
const functionModel = ref(false);
const searchTerm = ref("");
const fnSavedFunctionDialog = () => {
emit("save:function");
};
const filteredFunctionOptions = computed(() => {
if (!searchTerm.value) return props.functionOptions;
return props.functionOptions.filter((item) =>
item.name.toLowerCase().includes(searchTerm.value.toLowerCase()),
);
});
const applyFunction = (
item: { name: string; function: string },
flag = false,
) => {
emit("select:function", item, flag);
};
</script>
<style scoped lang="scss"></style>