Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import previous shell commands #9

Open
diegombeltran opened this issue Oct 5, 2020 · 3 comments
Open

Import previous shell commands #9

diegombeltran opened this issue Oct 5, 2020 · 3 comments

Comments

@diegombeltran
Copy link

It works flawlessly! Any chance to import previous commands into Loki?

@slim-bean
Copy link
Owner

Good question! yes there are probably a few ways to do this.

function _send_to_loki() {
(HISTTIMEFORMAT= builtin history -1 |
sed 's/^ *\([0-9]*\)\** *//' |
$HOME/.loki-shell/bin/promtail \
-config.file=$HOME/.loki-shell/config/promtail-logging-config.yaml \
--stdin -server.disable=true -log.level=error \
--client.external-labels=host=$HOST 2>&1 | logger -t loki-shell-promtail &)

I think you could modify the command used to send the files with promtail to dump the entire history and not just the last entry.

I haven't tested this myself, you may want to find a way to test this on a separate Loki, or maybe an ephemeral loki docker container with out any persistent storage just to make sure it does what you want (since we can't really delete from Loki yet, but this is coming in the future)

@Jab2870
Copy link

Jab2870 commented Oct 14, 2020

I think a solution to this (if timestamps can be brought across) would go a long way towards #10 .

@slim-bean
Copy link
Owner

I did this on a machine today, no timestamps but this works for importing the existing shell history

cat ~/.bash_history | $HOME/.loki-shell/bin/promtail -config.file=$HOME/.loki-shell/config/promtail-logging-config.yaml --stdin -server.disable=true -log.level=error --client.external-labels=host=$HOSTNAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants