Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat: restrict timestamp from adding it to query (#1517)

Pranshu Chittora166e5612ebdd
diff --git a/frontend/src/components/Logs/LogItem/index.tsx b/frontend/src/components/Logs/LogItem/index.tsx
index 5ddf160097..ba51b59373 100644
--- a/frontend/src/components/Logs/LogItem/index.tsx
+++ b/frontend/src/components/Logs/LogItem/index.tsx
@@ -2,6 +2,7 @@ import { blue, grey, orange } from '@ant-design/colors';
import { CopyFilled, CopyrightCircleFilled, ExpandAltOutlined } from '@ant-design/icons';
import { Button, Card, Divider, Row, Typography } from 'antd';
import { map } from 'd3';
+import dayjs from 'dayjs';
import { FlatLogData } from 'lib/logs/flatLogData';
import { flatMap, flatMapDeep } from 'lodash-es';
import React, { useCallback, useMemo } from 'react';
@@ -95,7 +96,7 @@ function LogItem({ logData }) {
)}
<LogGeneralField
fieldKey="timestamp"
- fieldValue={flattenLogData.timestamp}
+ fieldValue={dayjs(flattenLogData.timestamp / 1e6).format()}
/>
</div>
{'}'}
diff --git a/frontend/src/container/LogDetailedView/TableView.tsx b/frontend/src/container/LogDetailedView/TableView.tsx
index 9e55e34df9..8548cd4829 100644
--- a/frontend/src/container/LogDetailedView/TableView.tsx
+++ b/frontend/src/container/LogDetailedView/TableView.tsx
@@ -14,6 +14,9 @@ import React, { useMemo, useState } from 'react';
import ActionItem from './ActionItem';
+// Fields which should be restricted from adding it to query
+const RESTRICTED_FIELDS = ['timestamp'];
+
function TableView({ logData }) {
const [fieldSearchInput, setFieldSearchInput] = useState<string>('');
@@ -38,27 +41,33 @@ function TableView({ logData }) {
{
title: 'Action',
width: 75,
- render: (fieldData) => (
- <ActionItem
- fieldKey={fieldData.field.split('.').slice(-1)}
- fieldValue={fieldData.value}
- />
- ),
+ render: (fieldData) => {
+ const fieldKey = fieldData.field.split('.').slice(-1);
+ if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
+ return <ActionItem fieldKey={fieldKey} fieldValue={fieldData.value} />;
+ }
+ return null;
+ },
},
{
title: 'Field',
dataIndex: 'field',
key: 'field',
width: '35%',
- render: (field: string) => (
- <AddToQueryHOC
- fieldKey={field.split('.').slice(-1)}
- fieldValue={flattenLogData[field]}
- >
- {' '}
- <span style={{ color: blue[4] }}>{field}</span>
- </AddToQueryHOC>
- ),
+ render: (field: string) => {
+ const fieldKey = field.split('.').slice(-1);
+ const renderedField = <span style={{ color: blue[4] }}>{field}</span>;
+
+ if (!RESTRICTED_FIELDS.includes(fieldKey[0])) {
+ return (
+ <AddToQueryHOC fieldKey={fieldKey} fieldValue={flattenLogData[field]}>
+ {' '}
+ {renderedField}
+ </AddToQueryHOC>
+ );
+ }
+ return renderedField;
+ },
},
{
title: 'Value',
@@ -83,7 +92,7 @@ function TableView({ logData }) {
/>
<Table
// scroll={{ x: true }}
- tableLayout='fixed'
+ tableLayout="fixed"
dataSource={dataSource}
columns={columns}
pagination={false}
diff --git a/frontend/src/container/LogLiveTail/index.tsx b/frontend/src/container/LogLiveTail/index.tsx
index bc699c82a1..1521cbba56 100644
--- a/frontend/src/container/LogLiveTail/index.tsx
+++ b/frontend/src/container/LogLiveTail/index.tsx
@@ -110,7 +110,7 @@ function LogLiveTail() {
const timeStamp = dayjs().subtract(liveTailStartRange, 'minute').valueOf();
const queryParams = new URLSearchParams({
...(queryString ? { q: queryString } : {}),
- timestampStart: timeStamp,
+ timestampStart: timeStamp * 1e6,
...(liveTailSourceRef.current && logs.length > 0
? {
idGt: logs[0].id,