Skip to content

Instantly share code, notes, and snippets.

View kavirajk's full-sized avatar
😎
Talk distributed systems to me!!

Kaviraj Kanagaraj kavirajk

😎
Talk distributed systems to me!!
View GitHub Profile
@kavirajk
kavirajk / loki-ingest.md
Last active May 7, 2024 11:34
Experiment to reproduce and workaround ingest errors Loki

Reproduce and workaround too_far_behind error

Payload

{
  "streams": [
    {
      "stream": {
          "host": "localhost",
	        "app": "webserver1"
@kavirajk
kavirajk / bug.go
Created March 31, 2024 20:14
LogQL linefilters bug
package main
import (
"fmt"
"github.com/grafana/loki/pkg/logql/syntax"
)
func main() {
q := `{app="loki"}!= "foo" or "bar"` // with single linefilters
@kavirajk
kavirajk / instant-metric-query-bug-incorrect-results
Created March 19, 2024 09:58
Additional log lines to show the bug in action.
(first-time)
Debug!! val {} => 598 @[1710835200000] err <nil> expr sum(count_over_time({job="varlogs"} != "cache17"[1h]))
Debug!! val {} => 598 @[1710835200000] err <nil> expr sum(downstream<sum(count_over_time({job="varlogs"} != "cache17"[1h])), shard=<nil>>)
Debug!! val {} => 1803 @[1710831600000] err <nil> expr sum(count_over_time({job="varlogs"} != "cache17"[1h]))
Debug!! val {} => 1803 @[1710831600000] err <nil> expr sum(downstream<sum(count_over_time({job="varlogs"} != "cache17"[1h])), shard=<nil>>)
Debug!! val {} => 18 @[1710835690422] err <nil> expr sum(count_over_time({job="varlogs"} != "cache17"[8m10s422ms]))

Keybase proof

I hereby claim:

  • I am kavirajk on github.
  • I am kavirajk (https://keybase.io/kavirajk) on keybase.
  • I have a public key ASCeqna4pHeED4LBnMXTLyToZW-tn2fu4VucQs-OLLcqrAo

To claim this, I am signing this object:

@kavirajk
kavirajk / reset_password.go
Created July 15, 2016 11:29
Reset password (unable to mock)
package main
import (
"flag"
"fmt"
"log"
"code.launchyard.com/root/aircto-backend/config"
"code.launchyard.com/root/aircto-backend/models"
"code.launchyard.com/root/aircto-backend/utils"
package main
import (
"testing"
"code.launchyard.com/root/myserver/utils"
"code.launchyard.com/root/myserver/models"
)
@kavirajk
kavirajk / reset_password.go
Last active July 15, 2016 11:22
Resets User's password stored in db
// WARNING: This command is supposed to be used only by admin
package main
import (
"flag"
"fmt"
"log"
"code.launchyard.com/root/myserver/config"
@kavirajk
kavirajk / config_test.go
Created July 15, 2016 10:16
Test GetEnv function
package envron
import (
"os"
"os/exec"
"testing"
)
func TestMustEnv(t *testing.T) {
// If env variable "TEST" is not set then fatal it
@kavirajk
kavirajk / config.go
Created July 15, 2016 10:15
Load config from environment variables
package envron
import (
"log"
"os"
)
func MustEnv(key string) (value string) {
if value = os.Getenv(key); value == "" {
log.Fatalf("ENV %q is not set.", key)
@kavirajk
kavirajk / emails_test.go
Last active July 15, 2016 10:10
Send Email unit tests
package email
import (
"bytes"
"html/template"
"reflect"
"testing"
)
type FakeEmailSender struct {