Skip to content

Commit

Permalink
Merge pull request #405 from metrico/fix_404
Browse files Browse the repository at this point in the history
fix: database name in every table name
  • Loading branch information
akvlad authored Dec 6, 2023
2 parents d3c617c + f3570ea commit 0b677ea
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
7 changes: 7 additions & 0 deletions qryn_bun.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import handlerDelGroup from './lib/handlers/alerts/del_group.js'
import handlerDelNS from './lib/handlers/alerts/del_ns.js'
import handlerPromGetRules from './lib/handlers/alerts/prom_get_rules.js'
import handlerTail from './lib/handlers/tail.js'
import handlerTempoLabelV2 from './lib/handlers/tempo_v2_tags.js'
import handlerTempoLabelV2Values from './lib/handlers/tempo_v2_values.js'

import { readonly } from './common.js'
import DATABASE, { init } from './lib/db/clickhouse.js'
Expand Down Expand Up @@ -312,6 +314,11 @@ export default async() => {
'*': otlpPushProtoParser
})

fastify.get('/api/v2/search/tags', handlerTempoLabelV2)
fastify.get('/tempo/api/v2/search/tags', handlerTempoLabelV2)
fastify.get('/api/v2/search/tag/:name/values', handlerTempoLabelV2Values)
fastify.get('/tempo/api/v2/search/tag/:name/values', handlerTempoLabelV2Values)

const serveView = fs.existsSync(path.join(__dirname, 'view/index.html'))
if (serveView) {
app.plug(group(path.join(__dirname, 'view')));
Expand Down
22 changes: 12 additions & 10 deletions traceql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { clusterName } = require('../common')
const { DATABASE_NAME } = require('../lib/utils')
const dist = clusterName ? '_dist' : ''
const { rawRequest } = require('../lib/db/clickhouse')
const logger = require('../lib/logger')

/**
*
Expand All @@ -13,6 +14,7 @@ const { rawRequest } = require('../lib/db/clickhouse')
* @returns {Promise<[]>}
*/
const search = async (query, limit, from, to) => {
const _dbname = '`' + DATABASE_NAME() + '`'
const request = {
Request: query,
Ctx: {
Expand All @@ -22,19 +24,19 @@ const search = async (query, limit, from, to) => {
ToS: Math.floor(to.getTime() / 1000),
Limit: parseInt(limit),

TimeSeriesGinTableName: 'time_series_gin',
SamplesTableName: `samples_v3${dist}`,
TimeSeriesTableName: 'time_series',
TimeSeriesDistTableName: 'time_series_dist',
Metrics15sTableName: `metrics_15s${dist}`,
TimeSeriesGinTableName: `${_dbname}.time_series_gin`,
SamplesTableName: `${_dbname}.samples_v3${dist}`,
TimeSeriesTableName: `${_dbname}.time_series`,
TimeSeriesDistTableName: `${_dbname}.time_series_dist`,
Metrics15sTableName: `${_dbname}.metrics_15s${dist}`,

TracesAttrsTable: 'tempo_traces_attrs_gin',
TracesAttrsDistTable: 'tempo_traces_attrs_gin_dist',
TracesTable: 'tempo_traces',
TracesDistTable: 'tempo_traces_dist'
TracesAttrsTable: `${_dbname}.tempo_traces_attrs_gin`,
TracesAttrsDistTable: `${_dbname}.tempo_traces_attrs_gin_dist`,
TracesTable: `${_dbname}.tempo_traces`,
TracesDistTable: `${_dbname}.tempo_traces_dist`
}
}
console.log(JSON.stringify(request))
logger.debug(JSON.stringify(request))
const sql = TranspileTraceQL(request)
const response = await rawRequest(sql + ' FORMAT JSON', null, DATABASE_NAME())
const traces = response.data.data.map(row => ({
Expand Down

0 comments on commit 0b677ea

Please sign in to comment.