mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 09:05:37 +08:00 
			
		
		
		
	fix(metrics): don't assign a timestamp to Prometheus metrics, let the scraper assign the timestamp to the time series
This commit is contained in:
		
							parent
							
								
									fc98240614
								
							
						
					
					
						commit
						c0dfee8439
					
				
					 1 changed files with 1 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -43,7 +43,6 @@ interface MetricsData {
 | 
			
		|||
 */
 | 
			
		||||
function formatPrometheusMetrics(data: MetricsData): string {
 | 
			
		||||
    const lines: string[] = [];
 | 
			
		||||
    const timestamp = Math.floor(new Date(data.timestamp).getTime() / 1000);
 | 
			
		||||
 | 
			
		||||
    // Helper function to add a metric
 | 
			
		||||
    const addMetric = (name: string, value: number | null, help: string, type: string = 'gauge', labels: Record<string, string> = {}) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +55,7 @@ function formatPrometheusMetrics(data: MetricsData): string {
 | 
			
		|||
            ? `{${Object.entries(labels).map(([k, v]) => `${k}="${v}"`).join(',')}}`
 | 
			
		||||
            : '';
 | 
			
		||||
 | 
			
		||||
        lines.push(`${name}${labelStr} ${value} ${timestamp}`);
 | 
			
		||||
        lines.push(`${name}${labelStr} ${value}`);
 | 
			
		||||
        lines.push('');
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue