title: I need to send a slack message when a collection.find finds a task in failure in a mongodb database
body: <p>I need to be able to send a message to slack with the name of the collection in <code>MongoDB</code> when the query <code>collection.find()</code> finds in the DB a <code>task_status</code> in failure. So far it's what I've got and it works but I need the message to say the name of the collection, as this code is supposed to be used in a DB with a lot of collections, can someone help me?</p>
  <pre><code>import pymongo
  import requests
  import json
  from pymongo import MongoClient
  
  def slackmessage ():
      wekbook_url = 'https://hooks.slack.com/*****'
      slack_data = {
          'text': &quot;There is problem in your mongodb collection, task is in FAILURE.&quot;,
          'username': 'MongodbAlert',
          'icon_emoji': ':fire:'
      }
      response = requests.post(wekbook_url, data = json.dumps(slack_data), headers={'Content-Type': 'application/json'})
  
  def mongodbfind ():
      cluster = MongoClient(&quot;mongodb+srv://*****&quot;)
      db = cluster[&quot;nameofthemongodb&quot;]
      collection = db[&quot;nameofthecollection&quot;]
      mysearch = collection.find({ &quot;task_status&quot;:&quot;FAILURE&quot;})
      for x in mysearch:
          print (m + str(x))
          return True
          
  if mongocheck() == True:
      slackmessage()
  </code></pre>