Skip to content

Commit

Permalink
feat: parse search query in datav plugin #290
Browse files Browse the repository at this point in the history
  • Loading branch information
sunface committed Oct 25, 2023
1 parent 8f4df24 commit 52009cd
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 31 deletions.
5 changes: 5 additions & 0 deletions query/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ require (
require (
github.com/ClickHouse/ch-go v0.58.2 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand All @@ -54,13 +56,16 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/huandu/go-sqlbuilder v1.22.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mgudov/logic-expression-parser v0.1.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/paulmach/orb v0.10.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions query/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/ClickHouse/clickhouse-go/v2 v2.14.3/go.mod h1:qdw8IMGH4Y+PedKlf9QEhFO
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/bool64/shared v0.1.5 h1:fp3eUhBsrSjNCQPcSdQqZxxh9bBwrYiZ+zOKFkM0/2E=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
Expand Down Expand Up @@ -80,6 +82,11 @@ github.com/gosimple/slug v1.9.0 h1:r5vDcYrFz9BmfIAMC829un9hq7hKM4cHUrsv36LbEqs=
github.com/gosimple/slug v1.9.0/go.mod h1:AMZ+sOVe65uByN3kgEyf9WEBKBCSS+dJjMX9x4vDJbg=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U=
github.com/huandu/go-sqlbuilder v1.22.0 h1:69SpvXvhAoeb7y5uERUCB0/Ck09DwQ6ccYovejm1zHA=
github.com/huandu/go-sqlbuilder v1.22.0/go.mod h1:nUVmMitjOmn/zacMLXT0d3Yd3RHoO2K+vy906JzqxMI=
github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac h1:n1DqxAo4oWPMvH1+v+DLYlMCecgumhhgnxAPdqDIFHI=
github.com/inconshreveable/log15 v0.0.0-20201112154412-8562bdadbbac/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
Expand Down Expand Up @@ -114,8 +121,11 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/mgudov/logic-expression-parser v0.1.4 h1:oBAGk5RsAhBC2u0d9AZTYK3194iy9CuMmkLmUsEfo/k=
github.com/mgudov/logic-expression-parser v0.1.4/go.mod h1:XQJyAlRrbqsKd3NrlBQr1YmMvTyXId+rZDv8qXQArB4=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand All @@ -137,8 +147,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be h1:ta7tUOvsPHVHGom5hKW5VXNc2xZIkfCKP8iaqOyYtUQ=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
Expand Down
25 changes: 19 additions & 6 deletions query/internal/plugins/builtin/datav/api/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

ch "github.com/ClickHouse/clickhouse-go/v2"
datavmodels "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/models"
datavutils "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/utils"
pluginUtils "github.com/DataObserve/datav/query/internal/plugins/utils"
"github.com/DataObserve/datav/query/pkg/config"
"github.com/DataObserve/datav/query/pkg/models"
Expand All @@ -32,9 +33,9 @@ func GetLogs(c *gin.Context, ds *models.Datasource, conn ch.Conn, params map[str

if logId != "" {
// query logs
logsQuery := fmt.Sprintf(datavmodels.LogSelectSQL+" FROM %s.%s where timestamp = '%s' AND id = '%s'", config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable, logTs, logId)
logsQuery := fmt.Sprintf(datavmodels.LogSelectSQL+" FROM %s.%s where timestamp = ? AND id = ?", config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable)

rows, err := conn.Query(c.Request.Context(), logsQuery)
rows, err := conn.Query(c.Request.Context(), logsQuery, logTs, logId)
if err != nil {
logger.Warn("Error Query log", "query", logsQuery, "error", err)
return models.GenPluginResult(models.PluginStatusError, err.Error(), nil)
Expand All @@ -52,10 +53,22 @@ func GetLogs(c *gin.Context, ds *models.Datasource, conn ch.Conn, params map[str
return models.GenPluginResult(models.PluginStatusSuccess, "", res)
}

search := c.Query("search")
var searchQuery string
var searchArgs []interface{}
if search != "" {
var err error
searchQuery, searchArgs, err = datavutils.ParseSearchQuery(search)
if err != nil {
logger.Info("Error parse search query", "error", err, "query", search)
return models.GenPluginResult(models.PluginStatusError, "Parse search query error: "+err.Error(), nil)
}
}
// query logs
logsQuery := fmt.Sprintf(datavmodels.LogsSelectSQL+" FROM %s.%s where (timestamp >= %d AND timestamp <= %d) order by timestamp desc LIMIT %d OFFSET %d", config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable, start*1e9, (end)*1e9, perPageLogs, page*int64(perPageLogs))
logsQuery := fmt.Sprintf(datavmodels.LogsSelectSQL+" FROM %s.%s where (timestamp >= ? AND timestamp <= ? %s) order by timestamp desc LIMIT %d OFFSET %d", config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable, searchQuery, perPageLogs, page*int64(perPageLogs))

rows, err := conn.Query(c.Request.Context(), logsQuery)
args := append([]interface{}{start * 1e9, (end) * 1e9}, searchArgs...)
rows, err := conn.Query(c.Request.Context(), logsQuery, args...)
if err != nil {
logger.Warn("Error Query logs", "query", logsQuery, "error", err)
return models.GenPluginResult(models.PluginStatusError, err.Error(), nil)
Expand All @@ -73,9 +86,9 @@ func GetLogs(c *gin.Context, ds *models.Datasource, conn ch.Conn, params map[str
var res1 *models.PluginResultData
if page == 0 {
// query metrics
metricsQuery := fmt.Sprintf("SELECT toStartOfInterval(fromUnixTimestamp64Nano(timestamp), INTERVAL %d SECOND) AS ts_bucket, if(multiSearchAny(severity, ['error', 'err', 'emerg', 'alert', 'crit', 'fatal']), 'errors', 'others') as severity_group, count(*) as count from %s.%s where (timestamp >= %d AND timestamp <= %d) group by ts_bucket,severity_group order by ts_bucket", step, config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable, start*1e9, (end)*1e9)
metricsQuery := fmt.Sprintf("SELECT toStartOfInterval(fromUnixTimestamp64Nano(timestamp), INTERVAL %d SECOND) AS ts_bucket, if(multiSearchAny(severity, ['error', 'err', 'emerg', 'alert', 'crit', 'fatal']), 'errors', 'others') as severity_group, count(*) as count from %s.%s where (timestamp >= ? AND timestamp <= ? %s) group by ts_bucket,severity_group order by ts_bucket", step, config.Data.Observability.DefaultLogDB, datavmodels.DefaultLogsTable, searchQuery)

rows, err = conn.Query(c.Request.Context(), metricsQuery)
rows, err = conn.Query(c.Request.Context(), metricsQuery, args...)
if err != nil {
logger.Warn("Error Query log metrics", "query", metricsQuery, "error", err)
return models.GenPluginResult(models.PluginStatusError, err.Error(), nil)
Expand Down
10 changes: 5 additions & 5 deletions query/internal/plugins/builtin/datav/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

ch "github.com/ClickHouse/clickhouse-go/v2"
obmodels "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/models"
datavmodels "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/models"
pluginUtils "github.com/DataObserve/datav/query/internal/plugins/utils"
"github.com/DataObserve/datav/query/pkg/colorlog"
"github.com/DataObserve/datav/query/pkg/config"
Expand All @@ -21,7 +21,7 @@ type ServiceNameRes struct {
}

func GetServiceNames(c *gin.Context, ds *models.Datasource, conn ch.Conn, params map[string]interface{}) models.PluginResult {
query := fmt.Sprintf("SELECT DISTINCT serviceName FROM %s.%s", config.Data.Observability.DefaultTraceDB, obmodels.DefaultTopLevelOperationsTable)
query := fmt.Sprintf("SELECT DISTINCT serviceName FROM %s.%s", config.Data.Observability.DefaultTraceDB, datavmodels.DefaultTopLevelOperationsTable)

rows, err := conn.Query(c.Request.Context(), query)
if err != nil {
Expand All @@ -47,7 +47,7 @@ func GetServiceOperations(c *gin.Context, ds *models.Datasource, conn ch.Conn, p

service := serviceI.(string)

query := fmt.Sprintf("SELECT DISTINCT name FROM %s.%s WHERE serviceName='%s'", config.Data.Observability.DefaultTraceDB, obmodels.DefaultTopLevelOperationsTable, service)
query := fmt.Sprintf("SELECT DISTINCT name FROM %s.%s WHERE serviceName='%s'", config.Data.Observability.DefaultTraceDB, datavmodels.DefaultTopLevelOperationsTable, service)
rows, err := conn.Query(c.Request.Context(), query)
if err != nil {
logger.Warn("Error Query service operations", "query", query, "error", err)
Expand Down Expand Up @@ -101,7 +101,7 @@ func GetServiceInfoList(c *gin.Context, ds *models.Datasource, conn ch.Conn, par
FROM %s.%s
WHERE %s timestamp>= %d AND timestamp<= %d
GROUP BY serviceName`,
config.Data.Observability.DefaultTraceDB, obmodels.DefaultIndexTable, serviceFilter, start, end)
config.Data.Observability.DefaultTraceDB, datavmodels.DefaultIndexTable, serviceFilter, start, end)
args := []interface{}{}
args = append(args,
ch.Named("serviceNames", serviceNames),
Expand Down Expand Up @@ -135,7 +135,7 @@ func GetServiceInfoList(c *gin.Context, ds *models.Datasource, conn ch.Conn, par
FROM %s.%s
WHERE %s timestamp>= %d AND timestamp<= %d AND statusCode=2
GROUP BY serviceName`,
config.Data.Observability.DefaultTraceDB, obmodels.DefaultIndexTable, serviceFilter, start, end)
config.Data.Observability.DefaultTraceDB, datavmodels.DefaultIndexTable, serviceFilter, start, end)

rows, err = conn.Query(c.Request.Context(), query, args...)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion query/internal/plugins/builtin/datav/models/models.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package datavmodels
package models

const (
DefaultOperationsTable string = "distributed_signoz_operations"
Expand Down Expand Up @@ -27,3 +27,9 @@ const (
"timestamp, id, trace_id, span_id, trace_flags, severity, severity_number, body, namespace, service, host, " +
"CAST((attributes_string_key, attributes_string_value), 'Map(String, String)') as attributes_string,CAST((attributes_int64_key, attributes_int64_value), 'Map(String, Int64)') as attributes_int64, CAST((attributes_float64_key, attributes_float64_value), 'Map(String, Float64)') as attributes_float64, CAST((resources_string_key, resources_string_value), 'Map(String, String)') as resources_string "
)

type SearchToken struct {
Key string
Value string
Operator string
}
78 changes: 78 additions & 0 deletions query/internal/plugins/builtin/datav/utils/search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package utils

import (
"fmt"

sb "github.com/huandu/go-sqlbuilder"
lep "github.com/mgudov/logic-expression-parser"
)

func ParseSearchQuery(query string) (string, []interface{}, error) {
result, err := lep.ParseExpression(query)
if err != nil {
return "", nil, err
}

sql := sb.NewSelectBuilder()
where, err := traverse(sql, result)
if err != nil {
return "", nil, err
}
sql.Where(where)
s, args := sql.Build()

if s == "" {
return "", nil, nil
}

return "AND " + s[5:], args, nil
}

func traverse(sql *sb.SelectBuilder, expr lep.Expression) (string, error) {
switch e := expr.(type) {
default:
return "", fmt.Errorf("not implemented: %T", e)
case *lep.OrX:
var args []string
for _, disjunction := range e.Disjunctions {
arg, err := traverse(sql, disjunction)
if err != nil {
return "", err
}
args = append(args, arg)
}
return sql.Or(args...), nil
case *lep.AndX:
var args []string
for _, conjunct := range e.Conjuncts {
arg, err := traverse(sql, conjunct)
if err != nil {
return "", err
}
args = append(args, arg)
}
return sql.And(args...), nil
case *lep.EqualsX:
value := e.Value.Value()
if value == nil {
return sql.IsNotNull(e.Param.String()), nil
}
return sql.Equal(e.Param.String(), value), nil
case *lep.NotEqualsX:
value := e.Value.Value()
if value == nil {
return sql.IsNotNull(e.Param.String()), nil
}
return sql.NotEqual(e.Param.String(), value), nil
case *lep.GreaterThanX:
return sql.GreaterThan(e.Param.String(), e.Value.Value()), nil
case *lep.InSliceX:
var items []interface{}
for _, value := range e.Slice.Values {
items = append(items, value.Value())
}
return sql.In(e.Param.String(), items...), nil

// TODO: other cases
}
}
6 changes: 3 additions & 3 deletions query/internal/plugins/builtin/datav/utils/service.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package obutils
package utils

import (
"context"
"fmt"

ch "github.com/ClickHouse/clickhouse-go/v2"
obmodels "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/models"
datavmodels "github.com/DataObserve/datav/query/internal/plugins/builtin/datav/models"
"github.com/DataObserve/datav/query/pkg/config"
)

func GetServiceAndOperations(ctx context.Context, conn ch.Conn) (*map[string][]string, error) {
operations := map[string][]string{}
query := fmt.Sprintf(`SELECT DISTINCT name, serviceName FROM %s.%s`, config.Data.Observability.DefaultTraceDB, obmodels.DefaultTopLevelOperationsTable)
query := fmt.Sprintf(`SELECT DISTINCT name, serviceName FROM %s.%s`, config.Data.Observability.DefaultTraceDB, datavmodels.DefaultTopLevelOperationsTable)

rows, err := conn.Query(ctx, query)

Expand Down
5 changes: 4 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
"use-deep-compare-effect": "^1.8.1",
"use-immer": "^0.9.0",
"validator": "^13.5.2",
"viz.js": "1.8.1"
"viz.js": "1.8.1",
"@hyperdx/lucene": "^3.1.1",
"serialize-error": "^8.1.0",
"sqlstring": "^2.3.3"
},
"devDependencies": {
"@types/lodash": "^4.14.123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@ const LogDetail = ({ log: rawlog, isOpen, onClose, onSearch }: Props) => {
<TabPanel>
<VStack alignItems="left" fontSize="0.85rem">
{
basicKV.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`{{${r[0]}:${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}}}`,isNew)}/>)
basicKV.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`${r[0]}=${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}`,isNew)}/>)
}
</VStack>
<Text fontWeight={550} mt="4" fontSize="0.85rem">Resources</Text>
<Divider mt="2" />
<VStack alignItems="left" fontSize="0.85rem" mt="2">
{
log.resources.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`{{resources.${r[0]}:${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}}}}}`,isNew)}/>)
log.resources.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`resources.${r[0]}=${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}}}`,isNew)}/>)
}
</VStack>

<Text fontWeight={550} mt="4" fontSize="0.85rem">Attributes</Text>
<Divider mt="2" />
<VStack alignItems="left" fontSize="0.85rem" mt="2">
{
log.attributes.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`{{attributes.${r[0]}:${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}}}}}`,isNew)}/>)
log.attributes.map(r => <LogKV k={r[0]} v={r[1]} onSearch={(isNew) => onSearch(`attributes.${r[0]}=${typeof r[1] == "string" ? `"${r[1]}"`: r[1]}}}`,isNew)}/>)
}
</VStack>
</TabPanel>
Expand All @@ -112,7 +112,7 @@ const LogKV = ({ k, v, onSearch}) => {
<Text color="rgb(131, 120, 255)" minW="fit-content">{k}</Text>
<Text color={isString ? useColorModeValue("rgb(0, 166, 0)", "rgb(166, 226, 46)") : useColorModeValue("rgb(253, 130, 31)", "rgb(253, 151, 31)")} >{isString ? `"${v}"` : v}</Text>

<HStack opacity={0.6} fontSize="0.7rem" position="relative" visibility={onHover ? "visible" : "hidden"}>
<HStack opacity={0.5} fontSize="0.7rem" position="relative" visibility={onHover ? "visible" : "hidden"}>
<Tooltip label="Add to current search"><Box cursor="pointer"><FaSearchPlus onClick={() => onSearch(false)} /></Box></Tooltip>
<Tooltip label="Search with this value"><Box cursor="pointer"><FaSearch onClick={() => onSearch(true)}/></Box></Tooltip>
<CopyToClipboard copyText={v} tooltipTitle="copy this value" fontSize="0.7rem"/>
Expand Down
Loading

0 comments on commit 52009cd

Please sign in to comment.