Git Product home page Git Product logo

Comments (9)

ermGivelify avatar ermGivelify commented on June 18, 2024 5

How do track cron jobs so that I am alerted if they freeze (do not exit or have a really long run time)? Can that be done with DataDog?

from documentation.

clofresh avatar clofresh commented on June 18, 2024 1

You can use the dogwrap command that comes with the python client lib:

dogwrap -n myscript -k $API_KEY --submit_mode errors "/usr/local/bin/myscript.sh arg1 arg2"

This will call the command at the end of the script and send datadog events if it exits with a non-zero exit code. --submit_mode all will send events on every run.

(To get the python client lib you can install it with easy_install dogapi)

from documentation.

clofresh avatar clofresh commented on June 18, 2024

This is how we currently do it:

psql -c 'some maintenance query' 2>&1
    | tee -a /var/log/postgresql/maintenance.log
    | /usr/local/bin/dog event post --tags maintenance 'Doing some maintenance'

from documentation.

MisterRayCo avatar MisterRayCo commented on June 18, 2024

Is this up to date?

from documentation.

clofresh avatar clofresh commented on June 18, 2024

Yeah, that snippet would work. The pertinent part would be the "dog event post" part of the script. Needs some copy to explain the premise. Something like:

Often, you set cron jobs that trigger some meaningful script that you want to monitor and correlate with other metrics. For example, you might have a cron'd script to vacuum a Postgres table every day:

0 0 * * * psql -c 'vacuum verbose my_table' >> /var/log/postgres_vacuums.log 2>&1

Vacuum are particularly resource-intensive though, so you might want Datadog events for each time they run so you can correlate metrics and other events with vacuums. You can do this with the dog command line tool provided by the dogapi client library:

0 0 * * * psql -c 'vacuum verbose my_table' 2>&1 | tee -a /var/log/postgres_vacuums.log | /usr/local/bin/dog event post --tags maintenance 'Vacuuming my_table'

This will post an event tagged with #maintenance whose title is "Vacuuming my_table" and body has the log of the vacuum.

from documentation.

dmerrick avatar dmerrick commented on June 18, 2024

Another poke, is this still the official way to track cron runs?

from documentation.

dmerrick avatar dmerrick commented on June 18, 2024

This is exactly what I was looking for, thanks!

from documentation.

c0ze avatar c0ze commented on June 18, 2024

@clofresh sorry for digging this up. How can I install dogwrap these days ? Install dogapi didn't do it.

from documentation.

clofresh avatar clofresh commented on June 18, 2024

@c0ze I think dogapi is deprecated. Try pip install datadog instead. https://github.com/DataDog/datadogpy#installation

from documentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.