If your dog has vomited blood, use a clean object to scoop up a representative sample of the vomit and take it to the veterinarian. Tests can be done on the vomit to confirm whether blood is there, even if only trace amounts are present. Blood may come out in tiny flecks mixed in with fluids, as blood clots, or appear like coffee grounds if the digestive acids of the stomach have had time to break the blood down.
Assuming it is blood, a trip to the veterinarian is indicated. Causes of hematemesis, (our term for vomiting of blood) include ulcers of esophagus, stomach or upper intestines (may be associated with aspirin or steroid side effects), foreign material such as sharp bones in stomach or esophagus, cancers of the upper digestive tract, severe inflammatory conditions, and problems with the blood coagulation system. All of the potential causes require veterinary intervention. Sometimes a dog may have some blood move down through the digestive tract, discoloring the bowel movements a dark, tarry color (called melena). Note that a dog may actually have bleeding in the respiratory tract, and cough blood up into the oral cavity, then swallow it so that it comes out with vomit instead of the cough, so not all sources of blood are in the digestive tract.
To pinpoint causes of bloody vomit, a complete physical examination and health screen, including blood cell count, blood biochemistry panel, and urine sample are considered a starting point for the patient "work-up". Other tests such as clotting evaluations, stool samples, X-rays and ultrasound may also be required. Sometimes an endoscope is used to evaluate the esophagus and stomach to check for masses, ulcers etc., and to obtain tissue samples for biopsy or fluid for bacterial or fungal culture, or for parasite checks. If a case of bloody vomiting progresses, complications can occur such as anemia, infection, and rarely death in cases where a mass such as an ulcer perforates.